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.
Replaced custom philippines social form with generic component, driven by db configuration. For #90, but we still need to do more work here.
- Loading branch information
Showing
5 changed files
with
84 additions
and
64 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,38 @@ | ||
import Ember from 'ember'; | ||
import SelectValues from 'hospitalrun/utils/select-values'; | ||
export default Ember.Component.extend(SelectValues, { | ||
classNames: 'detail-section-content', | ||
fieldsByRow: function() { | ||
let rows = []; | ||
const form = this.get('form'); | ||
if (!Ember.isEmpty(form)) { | ||
const fields = form.fields; | ||
const numberOfColumns = this.getWithDefault('form.columns', 1); | ||
let currentRow = []; | ||
|
||
let colCount = 0; | ||
let colWidth = (12 / numberOfColumns); | ||
fields.forEach((field) => { | ||
if (!field.classNames) { | ||
field.classNames = ''; | ||
} | ||
let colSpan = field.colSpan || 1; | ||
if (colCount === numberOfColumns || (colCount + colSpan) > numberOfColumns) { | ||
rows.push(currentRow.slice()); | ||
currentRow = []; | ||
colCount = 0; | ||
} | ||
field.classNames += ' col-sm-' + (colWidth * colSpan); | ||
if (field.type === 'select') { | ||
field.mappedValues = field.values.map(this.selectValuesMap); | ||
} | ||
currentRow.push(field); | ||
colCount += colSpan; | ||
}); | ||
if (colCount > 0) { | ||
rows.push(currentRow); | ||
} | ||
} | ||
return rows; | ||
}.property('form') | ||
}); |
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
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
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
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,41 @@ | ||
{{#each fieldsByRow as |row|}} | ||
<div class="row form-group"> | ||
{{#each row as |field|}} | ||
{{#if (eq field.type 'radio')}} | ||
<div class="form-group {{field.classNames}}"> | ||
<label>{{field.label}}</label> | ||
{{ext-radio | ||
content=field.values | ||
value=(get model field.property) | ||
includeOtherOption=field.includeOtherOption | ||
otherOptionLabel=field.otherOptionLabel | ||
radioLabelPath="content" | ||
radioValuePath="content" | ||
}} | ||
</div> | ||
{{/if}} | ||
{{#if (eq field.type 'checkbox')}} | ||
<div class="form-group {{field.classNames}}"> | ||
<label>{{field.label}}</label> | ||
{{#each field.checkboxes as |checkbox|}} | ||
{{em-checkbox label=checkbox.label property=checkbox.property}} | ||
{{/each}} | ||
</div> | ||
{{/if}} | ||
{{#if (eq field.type 'textarea')}} | ||
{{em-text label=field.label property=field.property class=field.classNames}} | ||
{{/if}} | ||
{{#if (eq field.type 'text')}} | ||
{{em-input label=field.label property=field.property class=field.classNames}} | ||
{{/if}} | ||
{{#if (eq field.type 'select')}} | ||
{{em-select label=field.label | ||
property=field.property | ||
content=field.mappedValues | ||
class=field.classNames | ||
prompt=field.prompt | ||
}} | ||
{{/if}} | ||
{{/each}} | ||
</div> | ||
{{/each}} |