This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New component for operative plan and operation report
Component to add/maintain multiple procedures
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Ember from 'ember'; | ||
|
||
const { | ||
computed, | ||
isEmpty, | ||
get, | ||
set | ||
} = Ember; | ||
|
||
export function addProcedure(model) { | ||
let procedures = get(model, 'procedures'); | ||
let description = get(model, 'procedureDescription'); | ||
if (!isEmpty(description)) { | ||
procedures.addObject({ | ||
description | ||
}); | ||
set(model, 'procedureDescription', null); | ||
} | ||
} | ||
|
||
export default Ember.Component.extend({ | ||
model: null, | ||
procedureList: null, | ||
haveProcedures: computed('model.procedures.[]', { | ||
get() { | ||
return !isEmpty(get(this, 'model.procedures')); | ||
} | ||
}), | ||
|
||
actions: { | ||
addProcedure() { | ||
let model = get(this, 'model'); | ||
addProcedure(model); | ||
}, | ||
|
||
deleteProcedure(procedureToDelete) { | ||
let model = get(this, 'model'); | ||
let procedures = get(model, 'procedures'); | ||
procedures.removeObject(procedureToDelete); | ||
model.validate(); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<div class="row"> | ||
{{select-or-typeahead | ||
className=(concat (if (not-eq haveProcedures true) 'required ') 'procedure-description col-sm-10') | ||
property="procedureDescription" | ||
label=(t 'components.operativeProcedures.labels.procedure') list=procedureList | ||
selection=procedureDescription hint=false | ||
}} | ||
<div class="col-sm-2"> | ||
<label class="control-label"> </label> | ||
<p class=" form-control-static"> | ||
<button class="btn btn-primary" {{action 'addProcedure'}}> | ||
<span class="octicon octicon-plus"></span> {{t 'components.operativeProcedures.buttons.addProcedure'}} | ||
</button> | ||
</p> | ||
</div> | ||
</div> | ||
{{#if haveProcedures}} | ||
<h4>{{t 'components.operativeProcedures.titles.procedures'}}</h4> | ||
<table class="table"> | ||
<tr class="table-header"> | ||
<th>{{t 'components.operativeProcedures.labels.procedure'}}</th> | ||
<th>{{t 'labels.action'}}</th> | ||
</tr> | ||
{{#each model.procedures as |procedure|}} | ||
<tr> | ||
<td>{{procedure.description}}</td> | ||
<td> | ||
<button type="button" class="btn btn-default warning" {{action "deleteProcedure" procedure bubbles=false }}> | ||
<span class="octicon octicon-x"></span>{{t 'buttons.delete'}} | ||
</button> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</table> | ||
{{/if}} |