diff --git a/addon/components/array-input.hbs b/addon/components/array-input.hbs index ff9b0eb..de919ff 100644 --- a/addon/components/array-input.hbs +++ b/addon/components/array-input.hbs @@ -1,8 +1,16 @@ -
+
{{yield this.data}}
-
@@ -14,13 +22,19 @@ @value={{datum}} aria-label="Data Input" placeholder={{@placeholder}} + disabled={{this.disabled}} + class="form-input w-full flex-1 border-none shadow-none rounded-none pr-24" {{on "change" (fn this.onChange index)}} {{on "paste" (fn this.onPaste index)}} - class="form-input w-full flex-1 border-none shadow-none rounded-none pr-24" {{on "keyup" (fn this.inputDatum index)}} />
- +
{{/each}} diff --git a/addon/components/array-input.js b/addon/components/array-input.js index 78bf092..cc6ec8e 100644 --- a/addon/components/array-input.js +++ b/addon/components/array-input.js @@ -4,11 +4,13 @@ import { action } from '@ember/object'; export default class ArrayInputComponent extends Component { @tracked data = []; + @tracked disabled = false; - constructor() { + constructor(owner, { data = [], disabled = false }) { super(...arguments); - this.data = this.args.data ?? []; + this.data = data; + this.disabled = disabled; } @action onChange(index, event) { diff --git a/addon/components/button.js b/addon/components/button.js index 9e04667..d3f2abe 100644 --- a/addon/components/button.js +++ b/addon/components/button.js @@ -48,6 +48,13 @@ export default class ButtonComponent extends Component { return icon && !isLoading; } + /** + * The permission required. + * + * @memberof ButtonComponent + */ + @tracked permissionRequired; + /** * If the button is disabled by permissions. * diff --git a/addon/components/checkbox.hbs b/addon/components/checkbox.hbs index d885386..92b180d 100644 --- a/addon/components/checkbox.hbs +++ b/addon/components/checkbox.hbs @@ -1,32 +1,40 @@ -
-
- - {{#if @helpText}} - - - - {{/if}} -
- {{#if (has-block)}} -
- -
- {{else if @label}} -
- +{{#if this.visible}} +
+
+ + {{#if (has-block)}} +
+ +
+ {{else if @label}} +
+ +
+ {{/if}} + {{#if this.disabledByPermission}} + + + + {{else if @helpText}} + + + + {{/if}}
- {{/if}} -
\ No newline at end of file + +
+{{/if}} \ No newline at end of file diff --git a/addon/components/checkbox.js b/addon/components/checkbox.js index a0f3b57..42de8b5 100644 --- a/addon/components/checkbox.js +++ b/addon/components/checkbox.js @@ -1,9 +1,12 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { computed, action } from '@ember/object'; +import { inject as service } from '@ember/service'; import { guidFor } from '@ember/object/internals'; export default class CheckboxComponent extends Component { + @service abilities; + /** * Generates a unique ID for this checkbox instance * @@ -33,6 +36,44 @@ export default class CheckboxComponent extends Component { */ @tracked colorClass = 'text-sky-500'; + /** + * The permission required. + * + * @memberof CheckboxComponent + */ + @tracked permissionRequired; + + /** + * If the button is disabled by permissions. + * + * @memberof CheckboxComponent + */ + @tracked disabledByPermission = false; + + /** + * Determines the visibility of the button + * + * @memberof CheckboxComponent + */ + @tracked visible = true; + + /** + * Creates an instance of ButtonComponent. + * @param {*} owner + * @param {*} { permission = null } + * @memberof ButtonComponent + */ + constructor(owner, { value = false, permission = null, disabled = false, visible = true }) { + super(...arguments); + this.checked = value; + this.permissionRequired = permission; + this.visible = visible; + this.disabled = disabled; + if (!disabled) { + this.disabled = this.disabledByPermission = permission && this.abilities.cannot(permission); + } + } + /** * Toggles the checkbox and sends up an action * diff --git a/addon/components/content-panel.hbs b/addon/components/content-panel.hbs index 9f95b8f..82b3212 100644 --- a/addon/components/content-panel.hbs +++ b/addon/components/content-panel.hbs @@ -7,7 +7,7 @@ {{@panelHeaderClass}} {{if @isLoading 'is-loading'}}" > - + {{#unless @hideCaret}} @@ -49,6 +49,15 @@
{{/if}}
+ {{#if this.doesntHavePermissions}} + + + + {{else if @helpText}} + + + + {{/if}}
{{#if @titleRightSideComponent}} @@ -89,24 +98,31 @@ @iconPrefix={{button.iconPrefix}} @onClick={{button.onClick}} @wrapperClass={{button.wrapperClass}} + @permission={{button.permission}} + @disabled={{button.disabled}} class={{button.class}} /> {{/each}} {{#if @dropdownButton}} -