I am done for the night...

This commit is contained in:
Scott Idem
2024-03-08 00:09:17 -05:00
parent 1694dfb5c5
commit 5a147a98bb
18 changed files with 414 additions and 250 deletions

View File

@@ -86,6 +86,8 @@ onMount(() => {
// console.log(`ae_ ds_code_li = `, ds_code_li);
$: if (trigger == 'load__ds__code' && ds_code && ds_type) {
console.log(`ae_ load__ds__code: ${ds_code} ${ds_type} ${for_type} ${for_id} ${try_cache}`);
trigger = null;
load_data_store({
@@ -294,6 +296,8 @@ async function handle_submit_form(event) {
return ds_results;
})
.finally(function (ds_val_result) {
console.log(`ae_ ds_val_result = `, ds_val_result);
trigger = 'load__ds__code';
$ae_sess.ds.submit_status = 'created';
});
} else {
@@ -323,7 +327,10 @@ async function handle_submit_form(event) {
// .finally(function (ds_val_result) {
// // console.log(`ae_ ds_code_val = `, ds_val_result);
})
.finally(function (ds_val_result) {
.finally(function () {
// console.log(`ae_ ds_val_result = `, ds_val_result);
console.log(`ae_ load__ds__code: ${ds_code} ${ds_type} ${for_type} ${for_id} ${try_cache}`);
trigger = 'load__ds__code';
$ae_sess.ds.submit_status = 'updated';
});
}
@@ -376,31 +383,31 @@ async function handle_update__data_store({
$ae_sess.ds.update_status = 'starting';
ae_promises.update__data_store_obj = api.update_ae_obj_id_crud({
api_cfg: $ae_api,
obj_type: obj_type,
obj_id: obj_id,
fields: data,
key: $ae_api.api_crud_super_key,
log_lvl: 2
})
.then(async function (update__obj_result) {
if (!update__obj_result) {
console.log('The result was null or false.');
return false;
}
return update__obj_result;
api_cfg: $ae_api,
obj_type: obj_type,
obj_id: obj_id,
fields: data,
key: $ae_api.api_crud_super_key,
log_lvl: 2
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
.then(async function (update__obj_result) {
if (!update__obj_result) {
console.log('The result was null or false.');
return false;
})
.finally(function (update__obj_result) {
$ae_sess.ds.update_status = 'finished';
return update__obj_result;
})
}
return update__obj_result;
})
.catch(function (error) {
console.log('Something went wrong.');
console.log(error);
return false;
})
.finally(function (update__obj_result) {
$ae_sess.ds.update_status = 'finished';
return update__obj_result;
})
return ae_promises.update__data_store_obj;
return ae_promises.update__data_store_obj;
}
</script>
@@ -581,7 +588,7 @@ async function handle_update__data_store({
<button
type="submit"
class="btn variant-soft-primary"
disabled={ds_submit_results instanceof Promise}
disabled={ds_submit_results instanceof Promise && !ds_submit_results}
on:click={() => {
trigger = 'save__ds__code';
// $slct_trigger = 'save__ds__code';
@@ -600,10 +607,12 @@ async function handle_update__data_store({
</div>
{:then ds_submit_results}
{#if ds_submit_results}
<span class="fas fa-check text-green-500"></span>
<span class="saved-text">
Saved
</span>
<div>
<span class="fas fa-check text-green-500"></span>
<span class="saved-text">
Saved
</span>
</div>
{/if}
{/await}
@@ -644,6 +653,7 @@ async function handle_update__data_store({
type="button"
class="ae_btn_edit__ds btn hover:variant-glass-warning text-xs absolute top-0 right-0 opacity-75 hover:opacity-100 transition delay-700 hover:delay-200 m-1 p-1"
on:click={() => {
trigger = 'load__ds__code';
show_edit = true;
show_view = false;
}}