@humandialog/forms.svelte 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@humandialog/forms.svelte",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Basic Svelte UI components for Object Reef applications",
5
5
  "devDependencies": {
6
6
  "@playwright/test": "^1.28.1",
@@ -3,6 +3,7 @@
3
3
  FaUserMinus,
4
4
  FaPen,
5
5
  FaInfoCircle,
6
+ FaUserSlash,
6
7
  FaChevronDown} from 'svelte-icons/fa'
7
8
 
8
9
  import Page from './page.svelte'
@@ -267,8 +268,8 @@
267
268
 
268
269
  function create_new_user()
269
270
  {
270
- if(showAccessRoles)
271
- new_user.acc_role = access_roles[0].name
271
+ if(showAccessRoles && access_roles.length > 0)
272
+ new_user.acc_role = access_roles[0].name ?? ""
272
273
 
273
274
  create_new_user_enabled = true;
274
275
 
@@ -279,6 +280,14 @@
279
280
  icon: FaUserPlus,
280
281
  caption: '',
281
282
  action: (focused) => { create_new_user(); }
283
+ },
284
+ {
285
+ separator: true
286
+ },
287
+ {
288
+ icon: FaUserSlash,
289
+ caption: '',
290
+ action: (f) => {askToDeleteApplicationAccount();}
282
291
  }
283
292
  ]
284
293
 
@@ -586,6 +595,42 @@
586
595
  }
587
596
  }
588
597
 
598
+ let deleteAccountModal;
599
+ function askToDeleteApplicationAccount()
600
+ {
601
+ deleteAccountModal.show()
602
+ }
603
+
604
+ async function deleteApplicationAccount()
605
+ {
606
+ let my_email = $session.user.email ?? ""
607
+ if(!my_email)
608
+ return;
609
+
610
+ try{
611
+
612
+ const res = await reef.fetch(`json/anyv/sys/unregister_user?email=${my_email}`)
613
+ deleteAccountModal.hide();
614
+
615
+ if(res.ok)
616
+ {
617
+ $session.signout();
618
+ window.location.href = $signInHRef;
619
+ }
620
+ else
621
+ {
622
+ const err = await res.text()
623
+ alerts = [err, ...alerts];
624
+ }
625
+ }
626
+ catch(err)
627
+ {
628
+ deleteAccountModal.hide();
629
+
630
+ console.error(err)
631
+ alerts = [err, ...alerts];
632
+ }
633
+ }
589
634
 
590
635
  </script>
591
636
 
@@ -646,6 +691,7 @@
646
691
 
647
692
  </List>
648
693
  {/if}
694
+
649
695
 
650
696
  </Page>
651
697
 
@@ -805,4 +851,12 @@
805
851
  okCaption='Remove'
806
852
  onOkCallback={removeUser}
807
853
  bind:this={removeModal}
854
+ />
855
+
856
+ <Modal title="Delete app account"
857
+ content="Are you sure you want to delete your application account?"
858
+ icon={FaUserSlash}
859
+ okCaption='Delete'
860
+ onOkCallback={deleteApplicationAccount}
861
+ bind:this={deleteAccountModal}
808
862
  />