@api-client/ui 0.6.6 → 0.6.8
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/build/src/elements/setup/internals/OrganizationSelector.js +2 -2
- package/build/src/elements/setup/internals/OrganizationSelector.js.map +1 -1
- package/build/src/md/button/internals/base.d.ts +4 -1
- package/build/src/md/button/internals/base.d.ts.map +1 -1
- package/build/src/md/button/internals/base.js +4 -0
- package/build/src/md/button/internals/base.js.map +1 -1
- package/build/src/modeling/internals/DomainAutoFieldsDialog.d.ts.map +1 -1
- package/build/src/modeling/internals/DomainAutoFieldsDialog.js +11 -16
- package/build/src/modeling/internals/DomainAutoFieldsDialog.js.map +1 -1
- package/build/src/services/OrganizationService.d.ts +44 -6
- package/build/src/services/OrganizationService.d.ts.map +1 -1
- package/build/src/services/OrganizationService.js +79 -24
- package/build/src/services/OrganizationService.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/elements/setup/internals/OrganizationSelector.ts +2 -2
- package/src/md/button/internals/base.ts +5 -1
- package/src/modeling/internals/DomainAutoFieldsDialog.ts +11 -16
- package/src/services/OrganizationService.ts +84 -25
|
@@ -73,7 +73,7 @@ let OrganizationSelector = (() => {
|
|
|
73
73
|
}));
|
|
74
74
|
}
|
|
75
75
|
render() {
|
|
76
|
-
return html
|
|
76
|
+
return html `${this.renderTrigger()} ${this.renderMenu()}`;
|
|
77
77
|
}
|
|
78
78
|
renderTrigger() {
|
|
79
79
|
const { organization } = this;
|
|
@@ -84,7 +84,7 @@ let OrganizationSelector = (() => {
|
|
|
84
84
|
aria-label="Current organization: ${orgName}"
|
|
85
85
|
trailingicon
|
|
86
86
|
color="tonal"
|
|
87
|
-
|
|
87
|
+
popovertarget="org-selector-menu"
|
|
88
88
|
>
|
|
89
89
|
${orgName}
|
|
90
90
|
<ui-icon slot="icon">arrow_drop_down</ui-icon>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACtC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YAC/B,CAAC;iBAAM,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gBAC5B,IAAI,CAAC,YAAY,EAAE,CAAA;YACrB,CAAC;QACH,CAAC;QAED;;;WAGG;QACO,YAAY,CAAC,eAAuB;YAC5C,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,MAAM,EAAE,EAAE,YAAY,EAAE,eAAe,EAAE;gBACzC,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,KAAK;aAChB,CAAC,CACH,CAAA;QACH,CAAC;QAED;;WAEG;QACO,YAAY;YACpB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,QAAQ,EAAE;gBACxB,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,KAAK;aAChB,CAAC,CACH,CAAA;QACH,CAAC;QAEkB,MAAM;YACvB,OAAO,IAAI,CAAA,
|
|
1
|
+
{"version":3,"file":"OrganizationSelector.js","sourceRoot":"","sources":["../../../../../src/elements/setup/internals/OrganizationSelector.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAkB,UAAU,EAAE,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAsB,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;;sBAqBxB,UAAU;;;;;;;iBAAvC,oBAAqB,SAAQ,WAAU;;;wCAOzD,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,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QAAQ,EAAE;gBACxB,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,KAAK;aAChB,CAAC,CACH,CAAA;QACH,CAAC;QAEkB,MAAM;YACvB,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAA;QAC3D,CAAC;QAES,aAAa;YACrB,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAA;YAC7B,MAAM,OAAO,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAA;YACxE,OAAO,IAAI,CAAA;;;4CAG6B,OAAO;;;;;UAKzC,OAAO;;;KAGZ,CAAA;QACH,CAAC;QAES,UAAU;YAClB,MAAM,EAAE,YAAY,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;YACjD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;YACnD,OAAO,IAAI,CAAA;gEACiD,IAAI,CAAC,eAAe;UAC1E,MAAM,CACN,aAAa,EACb,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,EAChB,CAAC,GAAG,EAAE,EAAE,CACN,IAAI,CAAA;;;uBAGO,GAAG,CAAC,GAAG;2BACH,GAAG,CAAC,GAAG,KAAK,MAAM;sBACvB,GAAG,CAAC,IAAI;4BACF,CACnB;;;;;;;KAOJ,CAAA;QACH,CAAC;;;;;;;AA3HH;;;;;;;;;;;;;;;;;;GAkBG;AACH,oCAyGC","sourcesContent":["import { html, TemplateResult, LitElement } from 'lit'\nimport { property } from 'lit/decorators.js'\nimport { repeat } from 'lit/directives/repeat.js'\nimport { consume } from '@lit/context'\nimport type { UiMenuItemElement } from '../../../md/menu/ui-menu-item.js'\nimport { type IOrganization, organizationContext } from '../../../providers/organization.js'\nimport { organizationsContext } from '../../../providers/organizations.js'\n\n/**\n * An element that allows selecting an organization from a list.\n * It renders a button with the current organization name that triggers a dropdown menu with available organizations.\n *\n * The component supports creating a new organization via a dedicated menu item.\n *\n * @example\n * ```html\n * <organization-selector\n * .organization=\"${this.selectedOrg}\"\n * .organizations=\"${this.availableOrgs}\"\n * @select=\"${this.handleSelection}\"\n * @create=\"${this.handleCreate}\"\n * ></organization-selector>\n * ```\n *\n * @fires select - Dispatched when the user selects an organization. The detail object contains the `organization` key.\n * @fires create - Dispatched when the user clicks on the \"New Organization\" menu item.\n */\nexport default class OrganizationSelector extends LitElement {\n /**\n * The currently selected organization, if any.\n * When set, the button label will show this organization's name.\n *\n * This property consumes the `organizationContext`.\n */\n @property({ type: Object, attribute: false })\n @consume({ context: organizationContext, subscribe: true })\n accessor organization: IOrganization | undefined\n\n /**\n * The list of available organizations to display in the dropdown menu.\n *\n * This property consumes the `organizationsContext`.\n */\n @property({ type: Array, attribute: false })\n @consume({ context: organizationsContext, subscribe: true })\n accessor organizations: IOrganization[] | undefined\n\n /**\n * A handler for organization selection from the menu.\n */\n protected handleOrgSelect(e: CustomEvent<{ item: UiMenuItemElement }>): void {\n const { item } = e.detail\n const { action = '' } = item.dataset\n if (action === 'select' && item.value) {\n this.notifySelect(item.value)\n } else if (action === 'new') {\n this.notifyCreate()\n }\n }\n\n /**\n * Notifies about organization selection.\n * @param organizationKey The key of the organization that was selected by the user.\n */\n protected notifySelect(organizationKey: string): void {\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { organization: organizationKey },\n bubbles: false,\n composed: false,\n })\n )\n }\n\n /**\n * Notifies about the request to create a new organization.\n */\n protected notifyCreate(): void {\n this.dispatchEvent(\n new CustomEvent('create', {\n bubbles: false,\n composed: false,\n })\n )\n }\n\n protected override render(): unknown {\n return html`${this.renderTrigger()} ${this.renderMenu()}`\n }\n\n protected renderTrigger(): TemplateResult {\n const { organization } = this\n const orgName = organization ? organization.name : 'Select Organization'\n return html`\n <ui-button\n id=\"org-selector-anchor\"\n aria-label=\"Current organization: ${orgName}\"\n trailingicon\n color=\"tonal\"\n popovertarget=\"org-selector-menu\"\n >\n ${orgName}\n <ui-icon slot=\"icon\">arrow_drop_down</ui-icon>\n </ui-button>\n `\n }\n\n protected renderMenu(): TemplateResult {\n const { organization, organizations = [] } = this\n const orgKey = organization ? organization.key : ''\n return html`\n <ui-menu id=\"org-selector-menu\" popover=\"auto\" @select=\"${this.handleOrgSelect}\">\n ${repeat(\n organizations,\n (org) => org.key,\n (org) =>\n html`<ui-menu-item\n showSelectionIcon\n data-action=\"select\"\n value=\"${org.key}\"\n ?selected=\"${org.key === orgKey}\"\n ><div>${org.name}</div>\n </ui-menu-item>`\n )}\n <ui-divider role=\"separator\"></ui-divider>\n <ui-menu-item data-action=\"new\">\n <div>New Organization</div>\n <ui-icon slot=\"start\">add</ui-icon>\n </ui-menu-item>\n </ui-menu>\n `\n }\n}\n"]}
|
|
@@ -80,6 +80,9 @@ export default class BaseButton extends UiElement {
|
|
|
80
80
|
/**
|
|
81
81
|
* Turns a `<ui-button>` element into a popover control button; takes the ID
|
|
82
82
|
* of the popover element to control as its value.
|
|
83
|
+
*
|
|
84
|
+
* Note: this is required for now as the spec only allows to control popovers
|
|
85
|
+
* via buttons. Custom elements are not allowed to control popovers.
|
|
83
86
|
* @attribute
|
|
84
87
|
*/
|
|
85
88
|
accessor popoverTarget: string | undefined;
|
|
@@ -95,7 +98,7 @@ export default class BaseButton extends UiElement {
|
|
|
95
98
|
* it will be shown; if the popover is showing, it will be hidden. If popoverTargetAction is omitted,
|
|
96
99
|
* "toggle" is the default action that will be performed by the control button.
|
|
97
100
|
*/
|
|
98
|
-
accessor popoverTargetAction:
|
|
101
|
+
accessor popoverTargetAction: 'hide' | 'show' | 'toggle' | undefined;
|
|
99
102
|
/**
|
|
100
103
|
* When true, the focus ring effect will be constrained to the inside of the button's bounds.
|
|
101
104
|
* @attribute
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../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UAAU,GAAG,IAAI;IAwBzC,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAsBpC;;;;OAIG;IACH,SAAS,CAAC,mBAAmB,IAAI,IAAI;IAqBrC,SAAS,CAAC,YAAY,IAAI,IAAI;IA6B9B,SAAS,CAAC,WAAW,IAAI,IAAI;IAKpB,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAKzC,kBAAkB,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;cAK/B,MAAM,IAAI,cAAc;IAW3C,SAAS,CAAC,UAAU,IAAI,cAAc;IAItC,SAAS,CAAC,eAAe,IAAI,cAAc;IAS3C,SAAS,CAAC,YAAY,IAAI,cAAc;CAGzC"}
|
|
@@ -202,6 +202,9 @@ let BaseButton = (() => {
|
|
|
202
202
|
/**
|
|
203
203
|
* Turns a `<ui-button>` element into a popover control button; takes the ID
|
|
204
204
|
* of the popover element to control as its value.
|
|
205
|
+
*
|
|
206
|
+
* Note: this is required for now as the spec only allows to control popovers
|
|
207
|
+
* via buttons. Custom elements are not allowed to control popovers.
|
|
205
208
|
* @attribute
|
|
206
209
|
*/
|
|
207
210
|
get popoverTarget() { return this.#popoverTarget_accessor_storage; }
|
|
@@ -379,6 +382,7 @@ let BaseButton = (() => {
|
|
|
379
382
|
element.showPopover();
|
|
380
383
|
}
|
|
381
384
|
else {
|
|
385
|
+
// default to toggle
|
|
382
386
|
element.togglePopover();
|
|
383
387
|
}
|
|
384
388
|
element.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../../src/md/button/internals/base.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA4C,MAAM,KAAK,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,oB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AAE,QAAQ,EAAE,CAAA;QACzB,CAAC;QAEkB,MAAM;YACvB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA;;;kBAGG,IAAI;iBACL,IAAI,CAAC,WAAW;sBACX,CAAA;QACpB,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AArXH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { nanoid } from 'nanoid'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\nimport { findElementInShadowRoots } from '../../../lib/Dom.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '../../focus-ring/ui-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n /**\n * Turns a `<ui-button>` element into a popover control button; takes the ID\n * of the popover element to control as its value.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor popoverTarget: string | undefined\n /**\n * Specifies the action to be performed on a popover element being controlled\n * by a control <ui-button>. Possible values are:\n *\n * - `hide` - The button will hide a shown popover. If you try to hide an already hidden popover,\n * no action will be taken.\n * - `show` - The button will show a hidden popover. If you try to show an already showing popover,\n * no action will be taken.\n * - `toggle` - The button will toggle a popover between showing and hidden. If the popover is hidden,\n * it will be shown; if the popover is showing, it will be hidden. If popoverTargetAction is omitted,\n * \"toggle\" is the default action that will be performed by the control button.\n */\n @property({ type: String, reflect: true }) accessor popoverTargetAction: string | undefined\n /**\n * When true, the focus ring effect will be constrained to the inside of the button's bounds.\n * @attribute\n */\n @property({ type: Boolean }) accessor inwardFocus: boolean | undefined\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override update(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('popoverTarget')) {\n this.setupPopoverTarget()\n }\n super.update(changedProperties)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (this.type === 'reset' && (!reason || allowedReasons)) {\n this.handleReset()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.handlePopoverAction()\n // Delegate to ActionController to properly end the press and reset phase\n // state; this removes the 'pressed' class via endPress() and ensures\n // subsequent pointerdown events work again.\n super.handleClick(e)\n }\n\n protected setupPopoverTarget(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n // A regular button first sets its value to the popover target ID,\n this.value = id\n // create an anchor association with the popover target\n if (!this.id) {\n this.id = nanoid()\n }\n const anchorName = `--anchor-${this.id}`\n this.style.setProperty('anchor-name', anchorName)\n element.style.setProperty('position-anchor', anchorName)\n this.setAttribute('aria-details', id)\n this.setAttribute('aria-controls', id)\n }\n\n /**\n * When the button has a popover target, this method toggles the popover\n * visibility by finding the element in the shadow roots and calling its\n * `togglePopover` method.\n */\n protected handlePopoverAction(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n const action = this.popoverTargetAction || 'toggle'\n if (action === 'hide') {\n element.hidePopover()\n } else if (action === 'show') {\n element.showPopover()\n } else {\n element.togglePopover()\n }\n element.focus()\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n protected handleReset(): void {\n const form = this.form as HTMLFormElement\n form?.reset()\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring\n part=\"focus-ring\"\n class=\"focus-ring\"\n .control=\"${this}\"\n ?inward=\"${this.inwardFocus}\"\n ></ui-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-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,CAAC;QAES,WAAW;YACnB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAuB,CAAA;YACzC,IAAI,EAAE,KAAK,EAAE,CAAA;QACf,CAAC;QAEQ,kBAAkB,CAAC,CAAe;YACzC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAA;YAC3B,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;QAC5B,CAAC;QAEQ,kBAAkB,CAAC,CAAe;YACzC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAA;YAC3B,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;QACzB,CAAC;QAEkB,MAAM;YACvB,MAAM,EAAE,YAAY,GAAG,KAAK,EAAE,GAAG,IAAI,CAAA;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,CAAA;YAE9B,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,CAAC,YAAY,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;;QAE9E,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO;KAChC,CAAA;QACH,CAAC;QAES,UAAU;YAClB,OAAO,IAAI,CAAA,2BAA2B,CAAA;QACxC,CAAC;QAES,eAAe;YACvB,OAAO,IAAI,CAAA;;;kBAGG,IAAI;iBACL,IAAI,CAAC,WAAW;sBACX,CAAA;QACpB,CAAC;QAES,YAAY;YACpB,OAAO,IAAI,CAAA,wCAAwC,IAAI,CAAC,QAAQ,gBAAgB,CAAA;QAClF,CAAC;;;AAzXH;;;;;;;;;;GAUG;AACH","sourcesContent":["import { html, nothing, type PropertyValues, type TemplateResult } from 'lit'\nimport { property, query } from 'lit/decorators.js'\nimport { nanoid } from 'nanoid'\nimport { UiElement } from '../../UiElement.js'\nimport type { BeginPressConfig, EndPressConfig } from '../../../controllers/ActionController.js'\nimport { isDisabled, setDisabled } from '../../../lib/disabled.js'\nimport type UiRipple from '../../ripple/internals/ripple.js'\nimport { findElementInShadowRoots } from '../../../lib/Dom.js'\n\nimport '../../ripple/ui-ripple.js'\nimport '../../focus-ring/ui-focus-ring.js'\n\nexport type ButtonType = 'submit' | 'reset' | 'button'\nexport type MdButtonShape = 'round' | 'square'\nexport type MdButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl'\n\n/**\n * A material design button with M3 Expressive features - CSS-native implementation.\n *\n * @slot icon - A slot for the icon element\n * @slot - The default slot for the label\n * @attribute {string} form - The form associated with this element when the element is outside the form.\n * @fires {ToggleEvent} toggle - Fired when the `toggle` property is true and the button is clicked,\n * changing its selection state.\n * The event's `newState` and `oldState` properties (string values: 'selected' or\n * 'unselected') detail this selection change.\n */\nexport default class BaseButton extends UiElement {\n static readonly formAssociated = true\n\n #internals = this.attachInternals()\n\n /**\n * The form associated with this element\n * @attribute\n */\n get form(): HTMLFormElement | null | string {\n return this.#internals.form\n }\n\n get validity() {\n return this.#internals.validity\n }\n\n get validationMessage() {\n return this.#internals.validationMessage\n }\n\n get willValidate() {\n return this.#internals.willValidate\n }\n\n /**\n * The name of the button, submitted as a pair with the button's value as part of the form data.\n * @attribute\n */\n @property({ type: String }) accessor name: string | undefined\n\n #value?: string\n\n get value(): string | undefined {\n return this.#value\n }\n\n /**\n * Defines the value associated with the button's name when it's submitted with the form data.\n * @attribute\n */\n @property({ type: String })\n set value(value: string | undefined) {\n if (this.#value === value) {\n return\n }\n this.#value = value\n this.#internals?.setFormValue(value || null)\n }\n\n /**\n * Whether to render the icon at the inline end of the label rather than the inline start.\n * @attribute\n */\n @property({ type: Boolean, attribute: 'trailingicon', reflect: true }) accessor trailingIcon = false\n\n /**\n * The default behavior of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor type: ButtonType = 'button'\n\n /**\n * When set, the button is a toggle button.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor toggle = false\n\n /**\n * Indicates that the button is currently selected.\n * @attribute\n */\n @property({ type: Boolean, reflect: true }) accessor selected = false\n\n /**\n * The shape of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor shape: MdButtonShape = 'round'\n\n /**\n * The size of the button.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor size: MdButtonSize = 's'\n\n get disabled(): boolean {\n return isDisabled(this)\n }\n\n /**\n * When set, the button is in a disabled state.\n * @attribute\n */\n @property({ reflect: true, type: Boolean })\n set disabled(value: boolean) {\n const old = isDisabled(this)\n setDisabled(this, value)\n this.requestUpdate('disabled', old)\n }\n\n @query('ui-ripple') protected accessor ripple!: UiRipple | null\n\n /**\n * Turns a `<ui-button>` element into a popover control button; takes the ID\n * of the popover element to control as its value.\n *\n * Note: this is required for now as the spec only allows to control popovers\n * via buttons. Custom elements are not allowed to control popovers.\n * @attribute\n */\n @property({ type: String, reflect: true }) accessor popoverTarget: string | undefined\n /**\n * Specifies the action to be performed on a popover element being controlled\n * by a control <ui-button>. Possible values are:\n *\n * - `hide` - The button will hide a shown popover. If you try to hide an already hidden popover,\n * no action will be taken.\n * - `show` - The button will show a hidden popover. If you try to show an already showing popover,\n * no action will be taken.\n * - `toggle` - The button will toggle a popover between showing and hidden. If the popover is hidden,\n * it will be shown; if the popover is showing, it will be hidden. If popoverTargetAction is omitted,\n * \"toggle\" is the default action that will be performed by the control button.\n */\n @property({ type: String, reflect: true }) accessor popoverTargetAction: 'hide' | 'show' | 'toggle' | undefined\n /**\n * When true, the focus ring effect will be constrained to the inside of the button's bounds.\n * @attribute\n */\n @property({ type: Boolean }) accessor inwardFocus: boolean | undefined\n\n constructor() {\n super()\n this.actionController.cancelKeyboardEvents = true\n this.addEventListener('keydown', this.handleKeyDown.bind(this))\n this.addEventListener('keyup', this.handleKeyUp.bind(this))\n this.addEventListener('click', this.handleClick.bind(this))\n this.addEventListener('pointerdown', this.handlePointerDown.bind(this))\n this.addEventListener('pointerup', this.handlePointerUp.bind(this))\n this.addEventListener('pointercancel', this.handlePointerCancel.bind(this))\n this.addEventListener('pointerleave', this.handlePointerLeave.bind(this))\n this.addEventListener('pointerenter', this.handlePointerEnter.bind(this))\n this.addEventListener('contextmenu', this.handleContextMenu.bind(this))\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n if (!this.hasAttribute('role')) {\n this.setAttribute('role', 'button')\n }\n if (!this.hasAttribute('tabindex') && !this.disabled) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n protected override update(changedProperties: PropertyValues<this>): void {\n if (changedProperties.has('popoverTarget')) {\n this.setupPopoverTarget()\n }\n super.update(changedProperties)\n }\n\n protected override updated(cp: PropertyValues<this>): void {\n super.updated(cp)\n\n // If the button is disabled, remove the tabindex attribute\n if (cp.has('disabled')) {\n if (this.disabled) {\n this.removeAttribute('tabindex')\n } else if (!this.hasAttribute('tabindex')) {\n this.setAttribute('tabindex', '0')\n }\n }\n\n if (cp.has('toggle') || cp.has('selected')) {\n this.updatePressedState()\n }\n }\n\n protected updatePressedState(): void {\n if (this.toggle) {\n this.ariaPressed = String(this.selected)\n } else {\n this.selected = false\n this.removeAttribute('aria-pressed')\n }\n }\n\n checkValidity() {\n return this.#internals.checkValidity()\n }\n\n reportValidity() {\n return this.#internals.reportValidity()\n }\n\n protected override firstUpdated(): void {\n this.#internals?.setFormValue(this.value || null)\n }\n\n override beginPress(options: BeginPressConfig): void {\n super.beginPress(options)\n this.classList.add('pressed')\n this.ripple?.beginFocus()\n }\n\n override endPress(config: EndPressConfig): void {\n super.endPress(config)\n this.classList.remove('pressed')\n this.ripple?.endFocus()\n const { cancelled, reason } = config\n if (cancelled) {\n return\n }\n const allowedReasons = reason === 'enter' || reason === 'space'\n if (this.type === 'submit' && (!reason || allowedReasons)) {\n this.handleSubmit()\n } else if (this.type === 'reset' && (!reason || allowedReasons)) {\n this.handleReset()\n } else if (allowedReasons) {\n this.click()\n }\n }\n\n override handleClick(e: MouseEvent): void {\n if (this.disabled) {\n e.preventDefault()\n e.stopPropagation()\n return\n }\n\n if (this.toggle) {\n this.selected = !this.selected\n const e = new ToggleEvent('toggle', {\n bubbles: true,\n composed: true,\n newState: this.selected ? 'selected' : 'unselected',\n oldState: this.selected ? 'unselected' : 'selected',\n })\n this.dispatchEvent(e)\n }\n this.handlePopoverAction()\n // Delegate to ActionController to properly end the press and reset phase\n // state; this removes the 'pressed' class via endPress() and ensures\n // subsequent pointerdown events work again.\n super.handleClick(e)\n }\n\n protected setupPopoverTarget(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n // A regular button first sets its value to the popover target ID,\n this.value = id\n // create an anchor association with the popover target\n if (!this.id) {\n this.id = nanoid()\n }\n const anchorName = `--anchor-${this.id}`\n this.style.setProperty('anchor-name', anchorName)\n element.style.setProperty('position-anchor', anchorName)\n this.setAttribute('aria-details', id)\n this.setAttribute('aria-controls', id)\n }\n\n /**\n * When the button has a popover target, this method toggles the popover\n * visibility by finding the element in the shadow roots and calling its\n * `togglePopover` method.\n */\n protected handlePopoverAction(): void {\n const id = this.popoverTarget\n if (!id) {\n return\n }\n const element = findElementInShadowRoots(id, this)\n if (!element) {\n return\n }\n const action = this.popoverTargetAction || 'toggle'\n if (action === 'hide') {\n element.hidePopover()\n } else if (action === 'show') {\n element.showPopover()\n } else {\n // default to toggle\n element.togglePopover()\n }\n element.focus()\n }\n\n protected handleSubmit(): void {\n const { name, value, type, disabled, form } = this\n if (!form || !type || disabled) {\n return\n }\n const typedForm = form as HTMLFormElement\n let button: HTMLButtonElement | undefined\n if (name || value) {\n button = document.createElement('button')\n if (name) {\n button.name = name\n }\n if (value) {\n button.value = value\n }\n button.type = type\n button.hidden = true\n typedForm.append(button)\n }\n try {\n typedForm.requestSubmit(button)\n } catch {\n // Ignore errors\n }\n if (button) {\n typedForm.removeChild(button)\n }\n }\n\n protected handleReset(): void {\n const form = this.form as HTMLFormElement\n form?.reset()\n }\n\n override handlePointerEnter(e: PointerEvent): void {\n super.handlePointerEnter(e)\n this.ripple?.beginHover(e)\n }\n\n override handlePointerLeave(e: PointerEvent): void {\n super.handlePointerLeave(e)\n this.ripple?.endHover()\n }\n\n protected override render(): TemplateResult {\n const { trailingIcon = false } = this\n const icon = this.renderIcon()\n\n return html`\n ${this.renderFocusRing()} ${this.renderRipple()} ${trailingIcon ? nothing : icon}\n <slot></slot>\n ${trailingIcon ? icon : nothing}\n `\n }\n\n protected renderIcon(): TemplateResult {\n return html`<slot name=\"icon\"></slot>`\n }\n\n protected renderFocusRing(): TemplateResult {\n return html`<ui-focus-ring\n part=\"focus-ring\"\n class=\"focus-ring\"\n .control=\"${this}\"\n ?inward=\"${this.inwardFocus}\"\n ></ui-focus-ring>`\n }\n\n protected renderRipple(): TemplateResult {\n return html`<ui-ripple class=\"ripple\" ?disabled=\"${this.disabled}\"></ui-ripple>`\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainAutoFieldsDialog.d.ts","sourceRoot":"","sources":["../../../../src/modeling/internals/DomainAutoFieldsDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAKhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU;IAC5D;;OAEG;IACM,QAAQ,CAAC,cAAc,cAAoB;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"DomainAutoFieldsDialog.d.ts","sourceRoot":"","sources":["../../../../src/modeling/internals/DomainAutoFieldsDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAKhC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,UAAU;IAC5D;;OAEG;IACM,QAAQ,CAAC,cAAc,cAAoB;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CA4J1B;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIX,MAAM,IAAI,cAAc;IAuBjC;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,OAAO,CAAC,WAAW;CAepB"}
|
|
@@ -42,10 +42,15 @@ let DomainAutoFieldsDialog = (() => {
|
|
|
42
42
|
name: 'Name',
|
|
43
43
|
description: 'A human-readable name for the record.',
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
id: 'display-name',
|
|
47
|
+
name: 'Display Name',
|
|
48
|
+
description: 'A user-friendly label for UI presentation.',
|
|
49
|
+
},
|
|
45
50
|
{
|
|
46
51
|
id: 'description',
|
|
47
52
|
name: 'Description',
|
|
48
|
-
description: 'A detailed description of the record.',
|
|
53
|
+
description: 'A detailed description of the record with support for markdown.',
|
|
49
54
|
},
|
|
50
55
|
{
|
|
51
56
|
id: 'public-unique-name',
|
|
@@ -62,6 +67,11 @@ let DomainAutoFieldsDialog = (() => {
|
|
|
62
67
|
name: 'Email Address',
|
|
63
68
|
description: 'Email address with verification support.',
|
|
64
69
|
},
|
|
70
|
+
{
|
|
71
|
+
id: 'role',
|
|
72
|
+
name: 'User Role',
|
|
73
|
+
description: 'Defines the access level or permissions for a user.',
|
|
74
|
+
},
|
|
65
75
|
{
|
|
66
76
|
id: 'first-name',
|
|
67
77
|
name: 'First Name',
|
|
@@ -139,21 +149,6 @@ let DomainAutoFieldsDialog = (() => {
|
|
|
139
149
|
},
|
|
140
150
|
],
|
|
141
151
|
},
|
|
142
|
-
{
|
|
143
|
-
name: 'Session & Security',
|
|
144
|
-
fields: [
|
|
145
|
-
{
|
|
146
|
-
id: 'session-id',
|
|
147
|
-
name: 'Session ID',
|
|
148
|
-
description: 'Unique identifier for user sessions.',
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
id: 'expires-at',
|
|
152
|
-
name: 'Expires At',
|
|
153
|
-
description: 'When a session or token expires.',
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
152
|
{
|
|
158
153
|
name: 'Audit Trail',
|
|
159
154
|
fields: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomainAutoFieldsDialog.js","sourceRoot":"","sources":["../../../../src/modeling/internals/DomainAutoFieldsDialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;;sBAUF,UAAU;;;;iBAAzC,sBAAuB,SAAQ,WAAU;;;0CAI3D,KAAK,EAAE;YAAC,+LAAS,cAAc,6BAAd,cAAc,uGAAoB;;;QAA3C,yFAA0B,IAAI,GAAG,EAAU;QAEpD;;WAEG;UAJiD;QAHpD;;WAEG;QACM,IAAS,cAAc,oDAAoB;QAA3C,IAAS,cAAc,0DAAoB;QAEpD;;WAEG;QACc,UAAU,gEAAwB;YACjD;gBACE,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,IAAI;wBACR,IAAI,EAAE,YAAY;wBAClB,WAAW,EAAE,gCAAgC;qBAC9C;oBACD;wBACE,EAAE,EAAE,MAAM;wBACV,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,uCAAuC;qBACrD;oBACD;wBACE,EAAE,EAAE,aAAa;wBACjB,IAAI,EAAE,aAAa;wBACnB,WAAW,EAAE,uCAAuC;qBACrD;oBACD;wBACE,EAAE,EAA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C;oBACtB,IAAI,CAAC,iBAAiB;;0BAEhB,aAAa;;;KAGlC,CAAA;QACH,CAAC;QAED;;WAEG;QACK,cAAc,CAAC,QAA2B;YAChD,OAAO,IAAI,CAAA;iDACkC,QAAQ,CAAC,IAAI;QACtD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC1D,CAAA;QACH,CAAC;QAED;;WAEG;QACK,WAAW,CAAC,KAA0B;YAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACpD,MAAM,OAAO,GAAG;gBACd,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,UAAU;aACvB,CAAA;YAED,OAAO,IAAI,CAAA;8CAC+B,KAAK,CAAC,EAAE,YAAY,QAAQ,CAAC,OAAO,CAAC;8CACrC,UAAU;6BAC3B,KAAK,CAAC,IAAI;sCACD,KAAK,CAAC,WAAW;;KAElD,CAAA;QACH,CAAC;;;AAhRH;;;;;GAKG;AACH,sCA2QC","sourcesContent":["import { html, type TemplateResult } from 'lit'\nimport { state } from 'lit/decorators.js'\nimport { LitElement } from 'lit'\nimport { classMap } from 'lit/directives/class-map.js'\nimport type { UiListSelection } from '../../md/list/ui-list.js'\nimport type { AutoFieldCategory, AutoFieldDefinition, AutoFieldsSelectionResult } from '../types.js'\n\n/**\n * A component for selecting \"auto fields\" to add to an entity.\n *\n * @fires select - Dispatched when fields are selected with AutoFieldsSelectionResult detail\n * @fires cancel - Dispatched when the user cancels the selection\n */\nexport default class DomainAutoFieldsDialog extends LitElement {\n /**\n * The currently selected field IDs\n */\n @state() accessor selectedFields = new Set<string>()\n\n /**\n * The auto field categories and definitions\n */\n private readonly categories: AutoFieldCategory[] = [\n {\n name: 'Core Fields',\n fields: [\n {\n id: 'id',\n name: 'Identifier',\n description: 'The unique ID for each record.',\n },\n {\n id: 'name',\n name: 'Name',\n description: 'A human-readable name for the record.',\n },\n {\n id: 'description',\n name: 'Description',\n description: 'A detailed description of the record.',\n },\n {\n id: 'public-unique-name',\n name: 'Public Unique Name (Slug)',\n description: 'A URL-friendly unique identifier (e.g., \"my-product\").',\n },\n ],\n },\n {\n name: 'User Information',\n fields: [\n {\n id: 'email',\n name: 'Email Address',\n description: 'Email address with verification support.',\n },\n {\n id: 'first-name',\n name: 'First Name',\n description: 'The first name of a person.',\n },\n {\n id: 'last-name',\n name: 'Last Name',\n description: 'The last name of a person.',\n },\n {\n id: 'phone',\n name: 'Phone Number',\n description: 'Phone number with international format support.',\n },\n {\n id: 'avatar-url',\n name: 'Avatar URL',\n description: 'URL to a profile picture or avatar image.',\n },\n ],\n },\n {\n name: 'Lifecycle & Status',\n fields: [\n {\n id: 'status',\n name: 'Status',\n description: 'The current state of the record (e.g., Active, Draft, Archived).',\n },\n {\n id: 'version',\n name: 'Version Number',\n description: 'Tracks changes to prevent editing conflicts.',\n },\n {\n id: 'owner',\n name: 'Owner',\n description: 'Reference to the user or team that owns this record.',\n },\n ],\n },\n {\n name: 'E-commerce',\n fields: [\n {\n id: 'price',\n name: 'Price',\n description: 'Product price with currency support.',\n },\n {\n id: 'unit-price',\n name: 'Unit Price',\n description: 'Price per unit with currency support.',\n },\n {\n id: 'sku',\n name: 'SKU',\n description: 'Stock Keeping Unit - unique product identifier.',\n },\n {\n id: 'quantity',\n name: 'Quantity',\n description: 'Available quantity or stock amount.',\n },\n {\n id: 'weight',\n name: 'Weight',\n description: 'Physical weight of the item.',\n },\n {\n id: 'images',\n name: 'Images',\n description: 'Multiple image URLs for the product.',\n },\n ],\n },\n {\n name: 'Session & Security',\n fields: [\n {\n id: 'session-id',\n name: 'Session ID',\n description: 'Unique identifier for user sessions.',\n },\n {\n id: 'expires-at',\n name: 'Expires At',\n description: 'When a session or token expires.',\n },\n ],\n },\n {\n name: 'Audit Trail',\n fields: [\n {\n id: 'created',\n name: 'Created At',\n description: 'The date and time when the record was created.',\n },\n {\n id: 'updated',\n name: 'Updated At',\n description: 'The date and time when the record was last updated.',\n },\n {\n id: 'updated-by',\n name: 'Updated By',\n description: 'Reference to the user who last updated the record.',\n },\n ],\n },\n {\n name: 'Soft Delete',\n fields: [\n {\n id: 'is-deleted',\n name: 'Is Deleted',\n description: 'A true/false flag indicating if the record is deleted.',\n },\n {\n id: 'deleted',\n name: 'Deleted At',\n description: 'The date and time when the record was deleted.',\n },\n ],\n },\n ]\n\n /**\n * Resets the selection\n */\n reset(): void {\n this.selectedFields.clear()\n this.requestUpdate()\n }\n\n /**\n * Handles field selection toggle\n */\n private handleFieldToggle(fieldId: string): void {\n if (this.selectedFields.has(fieldId)) {\n this.selectedFields.delete(fieldId)\n } else {\n this.selectedFields.add(fieldId)\n }\n this.requestUpdate()\n }\n\n private handleFieldSelect(e: CustomEvent<UiListSelection>): void {\n const { item } = e.detail\n const { id } = item.dataset\n if (!id) return\n this.handleFieldToggle(id)\n }\n\n /**\n * Handles the Add Selected button click\n */\n private handleAddSelected(): void {\n const result: AutoFieldsSelectionResult = {\n selectedFields: Array.from(this.selectedFields),\n }\n this.dispatchEvent(new CustomEvent('select', { detail: result }))\n }\n\n /**\n * Handles the Cancel button click\n */\n private handleCancel(): void {\n this.dispatchEvent(new CustomEvent('cancel'))\n }\n\n override render(): TemplateResult {\n const selectedCount = this.selectedFields.size\n\n return html`\n <ui-list class=\"list\" @select=\"${this.handleFieldSelect}\"\n >${this.categories.map((category) => this.renderCategory(category))}</ui-list\n >\n\n <div class=\"dialog-actions\">\n <ui-button type=\"button\" @click=\"${this.handleCancel}\" class=\"cancel\">Cancel</ui-button>\n <ui-button\n type=\"button\"\n class=\"save\"\n color=\"filled\"\n ?disabled=\"${selectedCount === 0}\"\n @click=\"${this.handleAddSelected}\"\n >\n Add Selected (${selectedCount})\n </ui-button>\n </div>\n `\n }\n\n /**\n * Renders a category section\n */\n private renderCategory(category: AutoFieldCategory): TemplateResult {\n return html`\n <div class=\"category-title title-medium\">${category.name}</div>\n ${category.fields.map((field) => this.renderField(field))}\n `\n }\n\n /**\n * Renders a field item\n */\n private renderField(field: AutoFieldDefinition): TemplateResult {\n const isSelected = this.selectedFields.has(field.id)\n const classes = {\n 'field-item': true,\n 'selected': isSelected,\n }\n\n return html`\n <ui-list-item image=\"avatar\" data-id=\"${field.id}\" class=\"${classMap(classes)}\" lines=\"two\">\n <ui-checkbox slot=\"start\" .checked=\"${isSelected}\"></ui-checkbox>\n <div class=\"label\">${field.name}</div>\n <div slot=\"supporting-text\">${field.description}</div>\n </ui-list-item>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"DomainAutoFieldsDialog.js","sourceRoot":"","sources":["../../../../src/modeling/internals/DomainAutoFieldsDialog.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAuB,MAAM,KAAK,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;;sBAUF,UAAU;;;;iBAAzC,sBAAuB,SAAQ,WAAU;;;0CAI3D,KAAK,EAAE;YAAC,+LAAS,cAAc,6BAAd,cAAc,uGAAoB;;;QAA3C,yFAA0B,IAAI,GAAG,EAAU;QAEpD;;WAEG;UAJiD;QAHpD;;WAEG;QACM,IAAS,cAAc,oDAAoB;QAA3C,IAAS,cAAc,0DAAoB;QAEpD;;WAEG;QACc,UAAU,gEAAwB;YACjD;gBACE,IAAI,EAAE,aAAa;gBACnB,MAAM,EAAE;oBACN;wBACE,EAAE,EAAE,IAAI;wBACR,IAAI,EAAE,YAAY;wBAClB,WAAW,EAAE,gCAAgC;qBAC9C;oBACD;wBACE,EAAE,EAAE,MAAM;wBACV,IAAI,EAAE,MAAM;wBACZ,WAAW,EAAE,uCAAuC;qBACrD;oBACD;wBACE,EAAE,EAAE,cAAc;wBAClB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AAa,KAAK,CAAC;oBACtB,IAAI,CAAC,iBAAiB;;0BAEhB,aAAa;;;KAGlC,CAAA;QACH,CAAC;QAED;;WAEG;QACK,cAAc,CAAC,QAA2B;YAChD,OAAO,IAAI,CAAA;iDACkC,QAAQ,CAAC,IAAI;QACtD,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC1D,CAAA;QACH,CAAC;QAED;;WAEG;QACK,WAAW,CAAC,KAA0B;YAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACpD,MAAM,OAAO,GAAG;gBACd,YAAY,EAAE,IAAI;gBAClB,UAAU,EAAE,UAAU;aACvB,CAAA;YAED,OAAO,IAAI,CAAA;8CAC+B,KAAK,CAAC,EAAE,YAAY,QAAQ,CAAC,OAAO,CAAC;8CACrC,UAAU;6BAC3B,KAAK,CAAC,IAAI;sCACD,KAAK,CAAC,WAAW;;KAElD,CAAA;QACH,CAAC;;;AA3QH;;;;;GAKG;AACH,sCAsQC","sourcesContent":["import { html, type TemplateResult } from 'lit'\nimport { state } from 'lit/decorators.js'\nimport { LitElement } from 'lit'\nimport { classMap } from 'lit/directives/class-map.js'\nimport type { UiListSelection } from '../../md/list/ui-list.js'\nimport type { AutoFieldCategory, AutoFieldDefinition, AutoFieldsSelectionResult } from '../types.js'\n\n/**\n * A component for selecting \"auto fields\" to add to an entity.\n *\n * @fires select - Dispatched when fields are selected with AutoFieldsSelectionResult detail\n * @fires cancel - Dispatched when the user cancels the selection\n */\nexport default class DomainAutoFieldsDialog extends LitElement {\n /**\n * The currently selected field IDs\n */\n @state() accessor selectedFields = new Set<string>()\n\n /**\n * The auto field categories and definitions\n */\n private readonly categories: AutoFieldCategory[] = [\n {\n name: 'Core Fields',\n fields: [\n {\n id: 'id',\n name: 'Identifier',\n description: 'The unique ID for each record.',\n },\n {\n id: 'name',\n name: 'Name',\n description: 'A human-readable name for the record.',\n },\n {\n id: 'display-name',\n name: 'Display Name',\n description: 'A user-friendly label for UI presentation.',\n },\n {\n id: 'description',\n name: 'Description',\n description: 'A detailed description of the record with support for markdown.',\n },\n {\n id: 'public-unique-name',\n name: 'Public Unique Name (Slug)',\n description: 'A URL-friendly unique identifier (e.g., \"my-product\").',\n },\n ],\n },\n {\n name: 'User Information',\n fields: [\n {\n id: 'email',\n name: 'Email Address',\n description: 'Email address with verification support.',\n },\n {\n id: 'role',\n name: 'User Role',\n description: 'Defines the access level or permissions for a user.',\n },\n {\n id: 'first-name',\n name: 'First Name',\n description: 'The first name of a person.',\n },\n {\n id: 'last-name',\n name: 'Last Name',\n description: 'The last name of a person.',\n },\n {\n id: 'phone',\n name: 'Phone Number',\n description: 'Phone number with international format support.',\n },\n {\n id: 'avatar-url',\n name: 'Avatar URL',\n description: 'URL to a profile picture or avatar image.',\n },\n ],\n },\n {\n name: 'Lifecycle & Status',\n fields: [\n {\n id: 'status',\n name: 'Status',\n description: 'The current state of the record (e.g., Active, Draft, Archived).',\n },\n {\n id: 'version',\n name: 'Version Number',\n description: 'Tracks changes to prevent editing conflicts.',\n },\n {\n id: 'owner',\n name: 'Owner',\n description: 'Reference to the user or team that owns this record.',\n },\n ],\n },\n {\n name: 'E-commerce',\n fields: [\n {\n id: 'price',\n name: 'Price',\n description: 'Product price with currency support.',\n },\n {\n id: 'unit-price',\n name: 'Unit Price',\n description: 'Price per unit with currency support.',\n },\n {\n id: 'sku',\n name: 'SKU',\n description: 'Stock Keeping Unit - unique product identifier.',\n },\n {\n id: 'quantity',\n name: 'Quantity',\n description: 'Available quantity or stock amount.',\n },\n {\n id: 'weight',\n name: 'Weight',\n description: 'Physical weight of the item.',\n },\n {\n id: 'images',\n name: 'Images',\n description: 'Multiple image URLs for the product.',\n },\n ],\n },\n {\n name: 'Audit Trail',\n fields: [\n {\n id: 'created',\n name: 'Created At',\n description: 'The date and time when the record was created.',\n },\n {\n id: 'updated',\n name: 'Updated At',\n description: 'The date and time when the record was last updated.',\n },\n {\n id: 'updated-by',\n name: 'Updated By',\n description: 'Reference to the user who last updated the record.',\n },\n ],\n },\n {\n name: 'Soft Delete',\n fields: [\n {\n id: 'is-deleted',\n name: 'Is Deleted',\n description: 'A true/false flag indicating if the record is deleted.',\n },\n {\n id: 'deleted',\n name: 'Deleted At',\n description: 'The date and time when the record was deleted.',\n },\n ],\n },\n ]\n\n /**\n * Resets the selection\n */\n reset(): void {\n this.selectedFields.clear()\n this.requestUpdate()\n }\n\n /**\n * Handles field selection toggle\n */\n private handleFieldToggle(fieldId: string): void {\n if (this.selectedFields.has(fieldId)) {\n this.selectedFields.delete(fieldId)\n } else {\n this.selectedFields.add(fieldId)\n }\n this.requestUpdate()\n }\n\n private handleFieldSelect(e: CustomEvent<UiListSelection>): void {\n const { item } = e.detail\n const { id } = item.dataset\n if (!id) return\n this.handleFieldToggle(id)\n }\n\n /**\n * Handles the Add Selected button click\n */\n private handleAddSelected(): void {\n const result: AutoFieldsSelectionResult = {\n selectedFields: Array.from(this.selectedFields),\n }\n this.dispatchEvent(new CustomEvent('select', { detail: result }))\n }\n\n /**\n * Handles the Cancel button click\n */\n private handleCancel(): void {\n this.dispatchEvent(new CustomEvent('cancel'))\n }\n\n override render(): TemplateResult {\n const selectedCount = this.selectedFields.size\n\n return html`\n <ui-list class=\"list\" @select=\"${this.handleFieldSelect}\"\n >${this.categories.map((category) => this.renderCategory(category))}</ui-list\n >\n\n <div class=\"dialog-actions\">\n <ui-button type=\"button\" @click=\"${this.handleCancel}\" class=\"cancel\">Cancel</ui-button>\n <ui-button\n type=\"button\"\n class=\"save\"\n color=\"filled\"\n ?disabled=\"${selectedCount === 0}\"\n @click=\"${this.handleAddSelected}\"\n >\n Add Selected (${selectedCount})\n </ui-button>\n </div>\n `\n }\n\n /**\n * Renders a category section\n */\n private renderCategory(category: AutoFieldCategory): TemplateResult {\n return html`\n <div class=\"category-title title-medium\">${category.name}</div>\n ${category.fields.map((field) => this.renderField(field))}\n `\n }\n\n /**\n * Renders a field item\n */\n private renderField(field: AutoFieldDefinition): TemplateResult {\n const isSelected = this.selectedFields.has(field.id)\n const classes = {\n 'field-item': true,\n 'selected': isSelected,\n }\n\n return html`\n <ui-list-item image=\"avatar\" data-id=\"${field.id}\" class=\"${classMap(classes)}\" lines=\"two\">\n <ui-checkbox slot=\"start\" .checked=\"${isSelected}\"></ui-checkbox>\n <div class=\"label\">${field.name}</div>\n <div slot=\"supporting-text\">${field.description}</div>\n </ui-list-item>\n `\n }\n}\n"]}
|
|
@@ -36,9 +36,53 @@ export default class OrganizationService extends Service {
|
|
|
36
36
|
*/
|
|
37
37
|
pendingOid: string | undefined | null;
|
|
38
38
|
protected onCreate(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use #setOrganization instead
|
|
41
|
+
*/
|
|
42
|
+
setupUserOrganization(org: IOrganization): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Sets an org as the current user org.
|
|
45
|
+
* @param org The organization to add.
|
|
46
|
+
*/
|
|
47
|
+
setOrganization(org: IOrganization): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Adds an organization to the list of organizations.
|
|
50
|
+
* It also updated the cache. Used when creating a new org.
|
|
51
|
+
* @param org The organization to add.
|
|
52
|
+
*/
|
|
53
|
+
addOrganization(org: IOrganization): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Removes an organization from the list of organizations.
|
|
56
|
+
* It also updated the cache. Used when deleting an org.
|
|
57
|
+
* @param org The organization to remove.
|
|
58
|
+
*/
|
|
59
|
+
removeOrganization(org: IOrganization): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use #readOrganization instead
|
|
62
|
+
*/
|
|
39
63
|
getUserOrganization(id: string): Promise<IOrganization>;
|
|
64
|
+
/**
|
|
65
|
+
* Reads an organization from the list of organizations.
|
|
66
|
+
* @param id The organization ID.
|
|
67
|
+
* @returns The organization.
|
|
68
|
+
*/
|
|
69
|
+
readOrganization(id: string): Promise<IOrganization>;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current user organization.
|
|
72
|
+
* @returns The current organization or undefined if not set.
|
|
73
|
+
*/
|
|
40
74
|
currentOrganization(): Promise<IOrganization | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* Checks if the user has a specific grant type in the current organization.
|
|
77
|
+
* @param grantType The grant type to check.
|
|
78
|
+
* @returns `true` if the user has the specified grant type, `false` otherwise.
|
|
79
|
+
*/
|
|
41
80
|
protected hasGrantType(grantType: UserOrganizationGrantType): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if the user has any of the specified grant types in the current organization.
|
|
83
|
+
* @param types The grant types to check.
|
|
84
|
+
* @returns `true` if the user has any of the specified grant types, `false` otherwise.
|
|
85
|
+
*/
|
|
42
86
|
hasRoles(types: UserOrganizationGrantType[]): Promise<boolean>;
|
|
43
87
|
/**
|
|
44
88
|
* Checks if the user is the owner of the current organization.
|
|
@@ -68,12 +112,6 @@ export default class OrganizationService extends Service {
|
|
|
68
112
|
* @returns The state of the organization creation.
|
|
69
113
|
*/
|
|
70
114
|
revalidate(): Promise<CompletionState>;
|
|
71
|
-
/**
|
|
72
|
-
* When the user has no organizations, it set the organization as the only one
|
|
73
|
-
* and persists the organization id as the selected organization.
|
|
74
|
-
* @param org The organization to add.
|
|
75
|
-
*/
|
|
76
|
-
setupUserOrganization(org: IOrganization): Promise<void>;
|
|
77
115
|
}
|
|
78
116
|
export {};
|
|
79
117
|
//# sourceMappingURL=OrganizationService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrganizationService.d.ts","sourceRoot":"","sources":["../../../src/services/OrganizationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AAI7G,aAAK,KAAK;IACR,UAAU,IAAA;IACV,QAAQ,IAAA;IACR,OAAO,IAAA;CACR;AAED,oBAAY,eAAe;IACzB;;OAEG;IACH,EAAE,IAAA;IACF;;OAEG;IACH,WAAW,IAAA;IACX;;OAEG;IACH,eAAe,IAAA;IACf;;OAEG;IACH,KAAK,IAAA;CACN;AAID,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;;IACtD,OAAgB,GAAG,SAA6B;IAEhD,KAAK,EAAE,KAAK,CAAmB;IAC/B,aAAa,EAAE,aAAa,EAAE,CAAK;IACnC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;cAYZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"OrganizationService.d.ts","sourceRoot":"","sources":["../../../src/services/OrganizationService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAA;AAI7G,aAAK,KAAK;IACR,UAAU,IAAA;IACV,QAAQ,IAAA;IACR,OAAO,IAAA;CACR;AAED,oBAAY,eAAe;IACzB;;OAEG;IACH,EAAE,IAAA;IACF;;OAEG;IACH,WAAW,IAAA;IACX;;OAEG;IACH,eAAe,IAAA;IACf;;OAEG;IACH,KAAK,IAAA;CACN;AAID,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,OAAO;;IACtD,OAAgB,GAAG,SAA6B;IAEhD,KAAK,EAAE,KAAK,CAAmB;IAC/B,aAAa,EAAE,aAAa,EAAE,CAAK;IACnC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC;;;;OAIG;IACH,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;cAYZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlD;;OAEG;IACH,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxD;;;OAGG;IACG,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD;;;;OAIG;IACG,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxD;;;;OAIG;IACG,kBAAkB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAa3D;;OAEG;IACH,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIvD;;;;OAIG;IACG,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAS1D;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAU/D;;;;OAIG;cACa,YAAY,CAAC,SAAS,EAAE,yBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAQpF;;;;OAIG;IACG,QAAQ,CAAC,KAAK,EAAE,yBAAyB,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAQpE;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIjC;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAInC;;;OAGG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC;;;;;;;;;;;OAWG;IACH,UAAU,IAAI,OAAO,CAAC,eAAe,CAAC;CAsFvC"}
|
|
@@ -49,8 +49,68 @@ export default class OrganizationService extends Service {
|
|
|
49
49
|
async onCreate() {
|
|
50
50
|
const url = new URL(window.location.href);
|
|
51
51
|
this.pendingOid = url.searchParams.get('oid');
|
|
52
|
+
this.revalidate();
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated Use #setOrganization instead
|
|
56
|
+
*/
|
|
57
|
+
setupUserOrganization(org) {
|
|
58
|
+
return this.setOrganization(org);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sets an org as the current user org.
|
|
62
|
+
* @param org The organization to add.
|
|
63
|
+
*/
|
|
64
|
+
async setOrganization(org) {
|
|
65
|
+
const hasOrg = this.organizations.some((i) => i.key === org.key);
|
|
66
|
+
if (!hasOrg) {
|
|
67
|
+
this.organizations.push(org);
|
|
68
|
+
}
|
|
69
|
+
const config = await services.get('config');
|
|
70
|
+
await config.local.set(CurrentOrganizationKey, org.key);
|
|
71
|
+
this.organizationId = org.key;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Adds an organization to the list of organizations.
|
|
75
|
+
* It also updated the cache. Used when creating a new org.
|
|
76
|
+
* @param org The organization to add.
|
|
77
|
+
*/
|
|
78
|
+
async addOrganization(org) {
|
|
79
|
+
const hasOrg = this.organizations.some((i) => i.key === org.key);
|
|
80
|
+
if (!hasOrg) {
|
|
81
|
+
this.organizations.push(org);
|
|
82
|
+
await this.#saveCache();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Removes an organization from the list of organizations.
|
|
87
|
+
* It also updated the cache. Used when deleting an org.
|
|
88
|
+
* @param org The organization to remove.
|
|
89
|
+
*/
|
|
90
|
+
async removeOrganization(org) {
|
|
91
|
+
const idx = this.organizations.findIndex((i) => i.key === org.key);
|
|
92
|
+
if (idx !== -1) {
|
|
93
|
+
this.organizations.splice(idx, 1);
|
|
94
|
+
await this.#saveCache();
|
|
95
|
+
if (this.organizationId === org.key) {
|
|
96
|
+
this.organizationId = undefined;
|
|
97
|
+
const config = await services.get('config');
|
|
98
|
+
await config.local.delete(CurrentOrganizationKey);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @deprecated Use #readOrganization instead
|
|
104
|
+
*/
|
|
105
|
+
getUserOrganization(id) {
|
|
106
|
+
return this.readOrganization(id);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reads an organization from the list of organizations.
|
|
110
|
+
* @param id The organization ID.
|
|
111
|
+
* @returns The organization.
|
|
112
|
+
*/
|
|
113
|
+
async readOrganization(id) {
|
|
54
114
|
await this.#updateComplete;
|
|
55
115
|
const org = this.organizations.find((i) => i.key === id);
|
|
56
116
|
if (!org) {
|
|
@@ -58,6 +118,10 @@ export default class OrganizationService extends Service {
|
|
|
58
118
|
}
|
|
59
119
|
return org;
|
|
60
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Gets the current user organization.
|
|
123
|
+
* @returns The current organization or undefined if not set.
|
|
124
|
+
*/
|
|
61
125
|
async currentOrganization() {
|
|
62
126
|
if (this.state === State.Checking) {
|
|
63
127
|
await this.#updateComplete;
|
|
@@ -65,10 +129,13 @@ export default class OrganizationService extends Service {
|
|
|
65
129
|
if (!this.organizationId) {
|
|
66
130
|
return undefined;
|
|
67
131
|
}
|
|
68
|
-
// TODO: we will store the orgs list in the local/session store
|
|
69
|
-
// so we won't be pinging server with every page reload.
|
|
70
132
|
return this.organizations.find((i) => i.key === this.organizationId);
|
|
71
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Checks if the user has a specific grant type in the current organization.
|
|
136
|
+
* @param grantType The grant type to check.
|
|
137
|
+
* @returns `true` if the user has the specified grant type, `false` otherwise.
|
|
138
|
+
*/
|
|
72
139
|
async hasGrantType(grantType) {
|
|
73
140
|
const org = await this.currentOrganization();
|
|
74
141
|
if (!org) {
|
|
@@ -76,6 +143,11 @@ export default class OrganizationService extends Service {
|
|
|
76
143
|
}
|
|
77
144
|
return org.grantType === grantType;
|
|
78
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Checks if the user has any of the specified grant types in the current organization.
|
|
148
|
+
* @param types The grant types to check.
|
|
149
|
+
* @returns `true` if the user has any of the specified grant types, `false` otherwise.
|
|
150
|
+
*/
|
|
79
151
|
async hasRoles(types) {
|
|
80
152
|
const org = await this.currentOrganization();
|
|
81
153
|
if (!org) {
|
|
@@ -120,9 +192,6 @@ export default class OrganizationService extends Service {
|
|
|
120
192
|
if (this.state === State.Checking) {
|
|
121
193
|
return this.#updateComplete;
|
|
122
194
|
}
|
|
123
|
-
if (this.organizationId) {
|
|
124
|
-
return Promise.resolve(CompletionState.OK);
|
|
125
|
-
}
|
|
126
195
|
this.state = State.Checking;
|
|
127
196
|
this.#updateComplete = new Promise((resolver) => {
|
|
128
197
|
this.#updateResolver = resolver;
|
|
@@ -158,20 +227,20 @@ export default class OrganizationService extends Service {
|
|
|
158
227
|
}
|
|
159
228
|
return false;
|
|
160
229
|
}
|
|
161
|
-
async #saveCache(
|
|
230
|
+
async #saveCache() {
|
|
162
231
|
const cache = await services.get('cache');
|
|
163
|
-
if (
|
|
232
|
+
if (this.organizations.length === 0) {
|
|
164
233
|
await cache.delete(OrgsCacheKey);
|
|
165
234
|
}
|
|
166
235
|
else {
|
|
167
|
-
await cache.set(OrgsCacheKey,
|
|
236
|
+
await cache.set(OrgsCacheKey, this.organizations, cache.TTL.OneHour);
|
|
168
237
|
}
|
|
169
238
|
}
|
|
170
239
|
async #callOrganizations() {
|
|
171
240
|
const sdk = await services.get('sdk');
|
|
172
241
|
const orgs = await sdk.organizations.list();
|
|
173
242
|
this.organizations = orgs.items || [];
|
|
174
|
-
await this.#saveCache(
|
|
243
|
+
await this.#saveCache();
|
|
175
244
|
}
|
|
176
245
|
#resolve(state) {
|
|
177
246
|
if (this.#updateResolver) {
|
|
@@ -204,19 +273,5 @@ export default class OrganizationService extends Service {
|
|
|
204
273
|
}
|
|
205
274
|
return result;
|
|
206
275
|
}
|
|
207
|
-
/**
|
|
208
|
-
* When the user has no organizations, it set the organization as the only one
|
|
209
|
-
* and persists the organization id as the selected organization.
|
|
210
|
-
* @param org The organization to add.
|
|
211
|
-
*/
|
|
212
|
-
async setupUserOrganization(org) {
|
|
213
|
-
const hasOrg = this.organizations.some((i) => i.key === org.key);
|
|
214
|
-
if (!hasOrg) {
|
|
215
|
-
this.organizations.push(org);
|
|
216
|
-
}
|
|
217
|
-
const config = await services.get('config');
|
|
218
|
-
await config.local.set(CurrentOrganizationKey, org.key);
|
|
219
|
-
this.organizationId = org.key;
|
|
220
|
-
}
|
|
221
276
|
}
|
|
222
277
|
//# sourceMappingURL=OrganizationService.js.map
|