Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert the type selector to a toggle #206

Merged
merged 2 commits into from Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions app/components/document-attachments.hbs
Expand Up @@ -30,19 +30,13 @@
<select class="au-c-custom-select" {{on "change" (perform this.onSelectDecision attachment)}}>
<option value="">{{t "attachments.typePlaceholder"}}</option>
{{#each @decisions as |decisionOption|}}
<option value={{decisionOption.uri}} selected={{eq attachment.decision decisionOption.uri}}>
{{decisionOption.title}}</option>
<option value={{decisionOption.uri}} selected={{eq attachment.decision decisionOption.uri}}>
{{decisionOption.title}}</option>
{{/each}}
</select>
</td>
<td class="au-c-custom-select-cell">
<select class="au-c-custom-select" {{on "change" (perform this.onSelectType attachment)}} disabled={{not attachment.decision}}>
<option value="">{{t "attachments.typePlaceholder"}}</option>
{{#each this.typeOptions as |typeOption|}}
<option value={{typeOption.id}} selected={{eq attachment.type.id typeOption.id}}>{{typeOption.label}}
</option>
{{/each}}
</select>
<td>
<AuToggleSwitch @label={{t "attachments.regulatory"}} @checked={{eq attachment.type.id this.regulatoryTypeId}} @onChange={{perform this.updateAttachmentIsRegulatory attachment}} />
</td>
<td class="au-u-text-right">
<AuButton @skin="tertiary" @alert={{true}} @icon="bin" @iconAlignment="left" {{on "click" (perform this.deleteAttachment attachment)}}>
Expand Down
18 changes: 7 additions & 11 deletions app/components/document-attachments.js
Expand Up @@ -14,22 +14,15 @@ export default class DocumentAttachmentsComponent extends Component {
@service intl;
@tracked attachments;
@tracked decisions;

typeOptions=[{
id: REGULATORY_TYPE_ID,
label: this.intl.t("attachments.regulatory")
}];

@tracked selectedType;
regulatoryTypeId = REGULATORY_TYPE_ID;

@task
*onSelectType(attachment, event){
const selectedId=event.target.value;
if(!selectedId){
*updateAttachmentIsRegulatory(attachment, isRegulatory) {
if(!isRegulatory){
attachment.type=null;
}
else{
const concept=yield this.store.findRecord('concept', selectedId);
const concept=yield this.store.findRecord('concept', REGULATORY_TYPE_ID);
attachment.type=concept;
}
yield attachment.save();
Expand Down Expand Up @@ -59,6 +52,9 @@ export default class DocumentAttachmentsComponent extends Component {

newAttachment.file = file;
newAttachment.documentContainer = documentContainer;
if (this.args.decisions.length === 1) {
newAttachment.decision = this.args.decisions[0];
}

yield newAttachment.save();

Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Expand Up @@ -83,6 +83,7 @@ module.exports = function (environment) {
ENV.manual.signee="#gebruikersbeheer";
ENV.manual.publisher="#gebruikersbeheer";
ENV.manual.print="";
ENV.featureFlags.attachments = true;
// ENV.APP.LOG_RESOLVER = true;
// ENV.APP.LOG_ACTIVE_GENERATION = true;
// ENV.APP.LOG_TRANSITIONS = true;
Expand Down