@humandialog/forms.svelte 1.2.5 → 1.3.1
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/components/Fab.svelte +8 -1
- package/components/Fab.svelte.d.ts +4 -1
- package/components/contextmenu.svelte +3 -11
- package/components/document/editor.svelte +166 -99
- package/components/document/internal/Document_command.d.ts +2 -0
- package/components/document/internal/Document_command.js +2 -0
- package/components/document/internal/palette.row.svelte +25 -3
- package/components/document/internal/palette.row.svelte.d.ts +9 -0
- package/components/document/internal/palette.svelte +104 -44
- package/components/inputbox.ltop.svelte.d.ts +6 -6
- package/components/simple.table.svelte.d.ts +2 -2
- package/components/table/_template.table.svelte.d.ts +2 -2
- package/components/tile.title.svelte.d.ts +2 -2
- package/desk.svelte +65 -13
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/modal.svelte +2 -0
- package/operations.svelte +27 -12
- package/package.json +3 -1
- package/page.svelte.d.ts +2 -2
- package/tenant.members.svelte +17 -5
- package/updates.js +9 -13
- package/utils.d.ts +7 -0
- package/utils.js +104 -3
package/tenant.members.svelte
CHANGED
|
@@ -68,10 +68,17 @@
|
|
|
68
68
|
{
|
|
69
69
|
if(showAccessRoles)
|
|
70
70
|
{
|
|
71
|
-
let roles = await reef.get('/sys/list_access_roles')
|
|
71
|
+
let roles = await reef.get('/sys/list_access_roles?details')
|
|
72
72
|
access_roles = [];
|
|
73
73
|
if(roles)
|
|
74
|
-
roles.forEach(
|
|
74
|
+
roles.forEach( roleInfo =>
|
|
75
|
+
access_roles.push(
|
|
76
|
+
{
|
|
77
|
+
name: roleInfo.name,
|
|
78
|
+
flags: roleInfo.flags,
|
|
79
|
+
id: roleInfo.id,
|
|
80
|
+
summary: roleInfo.summary ? roleInfo.summary : roleInfo.name
|
|
81
|
+
}));
|
|
75
82
|
}
|
|
76
83
|
|
|
77
84
|
|
|
@@ -659,7 +666,7 @@
|
|
|
659
666
|
|
|
660
667
|
{#if showAccessRoles}
|
|
661
668
|
<ListComboProperty name='Access' a='acc_role' onSelect={on_change_access_role}>
|
|
662
|
-
<ComboSource objects={access_roles} name='
|
|
669
|
+
<ComboSource objects={access_roles} name='summary' key='name'/>
|
|
663
670
|
</ListComboProperty>
|
|
664
671
|
{/if}
|
|
665
672
|
|
|
@@ -810,7 +817,7 @@
|
|
|
810
817
|
|
|
811
818
|
let options = [];
|
|
812
819
|
access_roles.forEach(k => options.push({
|
|
813
|
-
caption: k.
|
|
820
|
+
caption: k.summary,
|
|
814
821
|
action: (f) => { new_user.acc_role=k.name}
|
|
815
822
|
}));
|
|
816
823
|
|
|
@@ -818,7 +825,12 @@
|
|
|
818
825
|
let pt = new DOMPoint(rect.left, rect.bottom)
|
|
819
826
|
showMenu(pt, options);
|
|
820
827
|
}}>
|
|
821
|
-
{
|
|
828
|
+
{#if new_user.acc_role}
|
|
829
|
+
{access_roles.find(r => r.name==new_user.acc_role).summary}
|
|
830
|
+
{:else}
|
|
831
|
+
{"<none>"}
|
|
832
|
+
{/if}
|
|
833
|
+
|
|
822
834
|
<span class="w-3 h-3 inline-block text-stone-700 dark:text-stone-300 ml-2 mt-2 sm:mt-1">
|
|
823
835
|
<FaChevronDown/>
|
|
824
836
|
</span>
|
package/updates.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {writable} from 'svelte/store';
|
|
2
2
|
import {reef} from '@humandialog/auth.svelte/dist/index'
|
|
3
|
+
import {onErrorShowAlert} from './stores.js'
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
const modified_item_store = writable(null);
|
|
@@ -121,19 +122,14 @@ update_request_ticket.subscribe(async (v) => {
|
|
|
121
122
|
changes.push(value.item);
|
|
122
123
|
});
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const res = await reef.post('/Push', { Items: changes });
|
|
125
|
+
|
|
126
|
+
//console.log('push: ', changes);
|
|
127
|
+
const res = await reef.post('/Push', { Items: changes }, onErrorShowAlert);
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
catch(err)
|
|
135
|
-
{
|
|
136
|
-
console.error(err);
|
|
137
|
-
}
|
|
129
|
+
//if(res)
|
|
130
|
+
//{
|
|
131
|
+
modified_items_map.clear();
|
|
132
|
+
//}
|
|
133
|
+
|
|
138
134
|
}
|
|
139
135
|
})
|
package/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export function isDeviceSmallerThan(br: any): boolean;
|
|
|
2
2
|
export function selectItem(itm: any): void;
|
|
3
3
|
export function activateItem(context_level: any, itm: any, operations?: null): void;
|
|
4
4
|
export function clearActiveItem(context_level: any): void;
|
|
5
|
+
export function refreshToolbarOperations(): void;
|
|
5
6
|
export function isSelected(itm: any): boolean;
|
|
6
7
|
export function isActive(context_level: any, itm: any): boolean;
|
|
7
8
|
export function getActive(context_level: any): any;
|
|
@@ -25,6 +26,8 @@ export function getLast(array: any): any;
|
|
|
25
26
|
export function removeAt(array: any, index: any): any;
|
|
26
27
|
export function remove(array: any, element: any): any;
|
|
27
28
|
export function swapElements(array: any, e1: any, e2: any): any;
|
|
29
|
+
export function resizeImage(file: any, maxWidth?: number, maxHeight?: number, contentType?: string, quality?: number): Promise<any>;
|
|
30
|
+
export function isOnScreenKeyboardVisible(): boolean;
|
|
28
31
|
export namespace icons {
|
|
29
32
|
const symbols: null;
|
|
30
33
|
}
|
|
@@ -35,3 +38,7 @@ export namespace SCREEN_SIZES {
|
|
|
35
38
|
const xl: number;
|
|
36
39
|
}
|
|
37
40
|
export let currentEditable: null;
|
|
41
|
+
export namespace UI {
|
|
42
|
+
const operations: null;
|
|
43
|
+
const fab: null;
|
|
44
|
+
}
|
package/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getContext, tick } from "svelte";
|
|
2
2
|
import {get} from 'svelte/store'
|
|
3
|
-
import { contextItemsStore, contextToolbarOperations, data_tick_store } from "./stores";
|
|
3
|
+
import { contextItemsStore, contextToolbarOperations, pageToolbarOperations, data_tick_store } from "./stores";
|
|
4
|
+
import { Img } from "flowbite-svelte";
|
|
4
5
|
|
|
5
6
|
export let icons = {symbols :null}
|
|
6
7
|
|
|
@@ -76,6 +77,22 @@ export function clearActiveItem(context_level)
|
|
|
76
77
|
contextToolbarOperations.set( [] )
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
export function refreshToolbarOperations()
|
|
81
|
+
{
|
|
82
|
+
const contextOperations = get(contextToolbarOperations)
|
|
83
|
+
if(contextOperations && contextOperations.length)
|
|
84
|
+
{
|
|
85
|
+
contextToolbarOperations.set([...contextOperations])
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
{
|
|
90
|
+
const pageOperations = get(pageToolbarOperations);
|
|
91
|
+
if(pageOperations && pageOperations.length)
|
|
92
|
+
pageToolbarOperations.set([...pageOperations])
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
79
96
|
export function isSelected(itm)
|
|
80
97
|
{
|
|
81
98
|
let data_context = get(contextItemsStore);
|
|
@@ -162,7 +179,7 @@ export function editable(node, params)
|
|
|
162
179
|
case 'Enter':
|
|
163
180
|
e.stopPropagation();
|
|
164
181
|
e.preventDefault();
|
|
165
|
-
|
|
182
|
+
|
|
166
183
|
if(e.shiftKey && onSoftEnter)
|
|
167
184
|
await finish_editing({ softEnter: true});
|
|
168
185
|
else
|
|
@@ -211,11 +228,14 @@ export function editable(node, params)
|
|
|
211
228
|
if(active)
|
|
212
229
|
{
|
|
213
230
|
if(has_changed)
|
|
231
|
+
{
|
|
232
|
+
has_changed = false;
|
|
214
233
|
await action(node.textContent)
|
|
234
|
+
}
|
|
235
|
+
|
|
215
236
|
}
|
|
216
237
|
else
|
|
217
238
|
await action(node.textContent)
|
|
218
|
-
|
|
219
239
|
}
|
|
220
240
|
|
|
221
241
|
const finish_event = new CustomEvent("finish", {
|
|
@@ -522,3 +542,84 @@ export function swapElements(array, e1, e2)
|
|
|
522
542
|
|
|
523
543
|
return array;
|
|
524
544
|
}
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
export async function resizeImage(file, maxWidth=1024, maxHeight=1024, contentType='', quality=0.95)
|
|
548
|
+
{
|
|
549
|
+
if(!contentType)
|
|
550
|
+
contentType = file.type
|
|
551
|
+
|
|
552
|
+
if(!contentType)
|
|
553
|
+
contentType = 'image/png'
|
|
554
|
+
|
|
555
|
+
const calculateSize = (img, maxWidth, maxHeight) => {
|
|
556
|
+
let w = img.width,
|
|
557
|
+
h = img.height;
|
|
558
|
+
if (w > h) {
|
|
559
|
+
if (w > maxWidth) {
|
|
560
|
+
h = Math.round((h * maxWidth) / w);
|
|
561
|
+
w = maxWidth;
|
|
562
|
+
}
|
|
563
|
+
} else {
|
|
564
|
+
if (h > maxHeight) {
|
|
565
|
+
w = Math.round((w * maxHeight) / h);
|
|
566
|
+
h = maxHeight;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return [w, h];
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
return new Promise((resolve) => {
|
|
573
|
+
|
|
574
|
+
const img = new Image();
|
|
575
|
+
img.onerror = function () {
|
|
576
|
+
URL.revokeObjectURL(this.src)
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
img.onload = function () {
|
|
580
|
+
URL.revokeObjectURL(this.src)
|
|
581
|
+
const [newWidth, newHeight] = calculateSize(img, maxWidth, maxHeight);
|
|
582
|
+
|
|
583
|
+
console.log('resizeImage', img.width, '=>', newWidth, img.height, '=>', newHeight, contentType, quality)
|
|
584
|
+
|
|
585
|
+
const canvas = document.createElement("canvas");
|
|
586
|
+
canvas.width = newWidth;
|
|
587
|
+
canvas.height = newHeight;
|
|
588
|
+
const ctx = canvas.getContext("2d");
|
|
589
|
+
ctx.drawImage(img, 0, 0, newWidth, newHeight);
|
|
590
|
+
|
|
591
|
+
canvas.toBlob((blob) => {
|
|
592
|
+
resolve(blob);
|
|
593
|
+
},
|
|
594
|
+
|
|
595
|
+
contentType,
|
|
596
|
+
quality)
|
|
597
|
+
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
img.src = URL.createObjectURL(file);
|
|
601
|
+
|
|
602
|
+
})
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export function isOnScreenKeyboardVisible()
|
|
606
|
+
{
|
|
607
|
+
if(!isDeviceSmallerThan('sm')) // are we on mobile?
|
|
608
|
+
return false;
|
|
609
|
+
|
|
610
|
+
const sel = window.getSelection();
|
|
611
|
+
// if we have active selections then it's very possible we have onscreen keyboard visible, se we need to shrink window.innerHeight
|
|
612
|
+
if(sel && sel.rangeCount>0 && sel.focusNode && sel.focusNode.nodeType==sel.focusNode.TEXT_NODE)
|
|
613
|
+
{
|
|
614
|
+
const el = sel.focusNode.parentElement;
|
|
615
|
+
if(el && (el.isContentEditable || el.contentEditable == 'true' || el.tagName == 'INPUT'))
|
|
616
|
+
return true;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export const UI = {
|
|
623
|
+
operations: null,
|
|
624
|
+
fab: null
|
|
625
|
+
}
|