Files
threshold-ui/ui/admin/app/components/form/role/index.hbs
T

138 lines
4.3 KiB
Handlebars
Raw Normal View History

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: MPL-2.0
}}
2020-06-22 21:39:38 -04:00
<Rose::Form
@onSubmit={{@submit}}
@cancel={{@cancel}}
@disabled={{@model.isSaving}}
@showEditToggle={{if @model.isNew false true}}
2020-06-22 21:39:38 -04:00
as |form|
>
2022-12-21 09:42:13 -08:00
<Hds::Form::TextInput::Field
@isOptional={{true}}
2020-06-22 21:39:38 -04:00
@value={{@model.name}}
2022-12-21 09:42:13 -08:00
@isInvalid={{@model.errors.name}}
@type='text'
name='name'
disabled={{form.disabled}}
{{on 'input' (set-from-event @model 'name')}}
as |F|
>
2022-12-21 09:42:13 -08:00
<F.Label>{{t 'form.name.label'}}</F.Label>
<F.HelperText>{{t 'form.name.help'}}</F.HelperText>
2020-06-22 21:39:38 -04:00
{{#if @model.errors.name}}
2022-12-21 09:42:13 -08:00
<F.Error as |E|>
2020-06-22 21:39:38 -04:00
{{#each @model.errors.name as |error|}}
2022-12-21 09:42:13 -08:00
<E.Message>{{error.message}}</E.Message>
2020-06-22 21:39:38 -04:00
{{/each}}
2022-12-21 09:42:13 -08:00
</F.Error>
2020-06-22 21:39:38 -04:00
{{/if}}
2022-12-21 09:42:13 -08:00
</Hds::Form::TextInput::Field>
2020-06-22 21:39:38 -04:00
2022-12-21 09:42:13 -08:00
<Hds::Form::Textarea::Field
@isOptional={{true}}
2020-06-22 21:39:38 -04:00
@value={{@model.description}}
2022-12-21 09:42:13 -08:00
@isInvalid={{@model.errors.description}}
name='description'
disabled={{form.disabled}}
as |F|
>
2022-12-21 09:42:13 -08:00
<F.Label>{{t 'form.description.label'}}</F.Label>
<F.HelperText>{{t 'form.description.help'}}</F.HelperText>
2020-06-22 21:39:38 -04:00
{{#if @model.errors.description}}
2022-12-21 09:42:13 -08:00
<F.Error as |E|>
2020-06-22 21:39:38 -04:00
{{#each @model.errors.description as |error|}}
2022-12-21 09:42:13 -08:00
<E.Message>{{error.message}}</E.Message>
2020-06-22 21:39:38 -04:00
{{/each}}
2022-12-21 09:42:13 -08:00
</F.Error>
2020-06-22 21:39:38 -04:00
{{/if}}
2022-12-21 09:42:13 -08:00
</Hds::Form::Textarea::Field>
2020-06-22 21:39:38 -04:00
{{#unless @model.isNew}}
<fieldset
aria-labelledby='legend-text-grant-scope'
aria-describedby='helper-text-grant-scope'
>
2022-09-07 16:21:27 -04:00
<legend id='legend-text-grant-scope'>
2022-10-06 11:41:12 -04:00
{{t 'form.grant_scope.label'}}
2022-09-07 16:21:27 -04:00
</legend>
<Rose::Form::HelperText
@id='helper-text-grant-scope'
@error={{@model.errors.grant_scope_id}}
>
{{t 'form.grant_scope.help'}}
</Rose::Form::HelperText>
<form.radioGroup
@name='grant_scope_id'
@selectedValue={{@model.grant_scope_id}}
@changed={{this.updateGrantScopeID}}
as |radioGroup|
>
<Rose::Dropdown
@text={{@model.grantScope.displayName}}
@icon={{if
@model.grantScope.isProject
2021-09-16 14:03:26 -07:00
'flight-icons/svg/grid-16'
2021-08-25 10:52:20 -04:00
(if
@model.grantScope.isOrg
2021-09-16 14:03:26 -07:00
'flight-icons/svg/org-16'
'flight-icons/svg/globe-16'
2021-08-25 10:52:20 -04:00
)
}}
as |dropdown|
>
<ul>
{{#each @grantScopes as |grantScope|}}
<li class={{if grantScope.model.isProject 'is-project'}}>
<dropdown.item>
<radioGroup.radio
@label={{grantScope.model.displayName}}
@value={{grantScope.model.id}}
@icon={{concat 'app-icons/' grantScope.model.type}}
/>
</dropdown.item>
<ul class='indent-label-1'>
{{#each grantScope.subScopes as |subScope|}}
<li class={{if subScope.model.isProject 'is-project'}}>
<dropdown.item>
<radioGroup.radio
@label={{subScope.model.displayName}}
@value={{subScope.model.id}}
@icon={{concat 'app-icons/' subScope.model.type}}
/>
</dropdown.item>
<ul class='indent-label-2'>
{{#each subScope.subScopes as |subSubScope|}}
<li class={{if subSubScope.isProject 'is-project'}}>
<dropdown.item>
<radioGroup.radio
@label={{subSubScope.displayName}}
@value={{subSubScope.id}}
@icon={{concat 'app-icons/' subSubScope.type}}
/>
</dropdown.item>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</Rose::Dropdown>
</form.radioGroup>
</fieldset>
<br />
{{/unless}}
2021-08-12 10:35:33 -07:00
{{#if (can 'save model' @model)}}
<form.actions
@enableEditText={{t 'actions.edit-form'}}
@submitText={{t 'actions.save'}}
@cancelText={{t 'actions.cancel'}}
/>
{{/if}}
2022-10-06 11:41:12 -04:00
</Rose::Form>