-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from adiwg/feature-29-input-components
feature-29-input-components
- Loading branch information
Showing
28 changed files
with
1,162 additions
and
29 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,26 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
/** | ||
* Value of the input | ||
* | ||
* @property value | ||
* @type {Boolean} | ||
* @default false | ||
*/ | ||
value: false | ||
|
||
/** | ||
* Text to display next to the checkbox | ||
* | ||
* @property text | ||
* @type {String} | ||
*/ | ||
|
||
/** | ||
* The form label to display | ||
* | ||
* @property label | ||
* @type {String} | ||
*/ | ||
}); |
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,12 @@ | ||
<div class="form-group"> | ||
{{#if label}} | ||
<label>{{label}}</label> | ||
{{/if}} | ||
<div class="checkbox md-boolean"> | ||
<label> | ||
{{input type="checkbox" checked=value}} | ||
<span class="md-boolean-text">{{ text }}</span> | ||
</label> | ||
</div> | ||
{{yield}} | ||
</div> |
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,72 @@ | ||
import Ember from 'ember'; | ||
import MdCodelist from '../md-codelist/component'; | ||
|
||
export default MdCodelist.extend({ | ||
/** | ||
* Initial value. Accepts either an Array or JSON formatted array of strings. | ||
* Example: '["foo","bar"]' | ||
* | ||
* @property value | ||
* @type {Array|String} | ||
*/ | ||
|
||
/** | ||
* codelist is an array of code objects in mdCodelist format | ||
* the initial codelist for 'mdCodeName' is pulled from the 'codelist' service; | ||
* then if a new value was created by the user a new object will be added into the codelist; | ||
* then a new 'selected' element will be added to each codelist object to let select2 | ||
* and the template <option> tag know this item should be selected. | ||
* | ||
* @return {Array} | ||
*/ | ||
codelist: Ember.computed(function() { | ||
let codelist = []; | ||
let codelistName = this.get('mdCodeName'); | ||
let mdCodelist = this.get('mdCodes') | ||
.get(codelistName) | ||
.codelist | ||
.sortBy('codeName'); | ||
mdCodelist.forEach(function(item) { | ||
let newObject = { | ||
code: item['code'], | ||
codeName: item['codeName'], | ||
description: item['description'], | ||
selected: false | ||
}; | ||
codelist.pushObject(newObject); | ||
}); | ||
|
||
let val = this.get('value'); | ||
let selectedItems = typeof val === 'string' ? JSON.parse(val) : val; | ||
let create = this.get('create'); | ||
if(selectedItems) { | ||
if(create) { | ||
selectedItems.forEach(function(selectedItem) { | ||
let mdIndex = -1; | ||
codelist.forEach(function(codeObject, cIndex) { | ||
if(selectedItem === codeObject['codeName']) { | ||
mdIndex = cIndex; | ||
} | ||
}); | ||
if(mdIndex === -1) { | ||
let newObject = { | ||
code: Math.floor(Math.random() * 100000) + 1, | ||
codeName: selectedItem, | ||
description: 'Undefined', | ||
selected: false | ||
}; | ||
codelist.pushObject(newObject); | ||
} | ||
}); | ||
} | ||
codelist.forEach(function(item) { | ||
let mdIndex = selectedItems.indexOf(item['codeName']); | ||
if(mdIndex > -1) { | ||
item['selected'] = true; | ||
} | ||
}); | ||
} | ||
|
||
return codelist; | ||
}) | ||
}); |
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,13 @@ | ||
<div class="form-group"> | ||
{{#if label}} | ||
<label>{{label}}</label> | ||
{{/if}} | ||
<select class="form-control md-codelist md-codelist-multi" {{action 'setValue' on='change'}} multiple="multiple"> | ||
<option></option> | ||
{{#each codelist as |code index|}} | ||
<option value={{code.codeName}} selected={{code.selected}} | ||
data-tooltip={{code.description}}>{{code.codeName}}</option> | ||
{{/each}} | ||
{{yield}} | ||
</select> | ||
</div> |
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,17 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
/** | ||
* An object listing the icon classes | ||
* @type {Object} | ||
*/ | ||
calendarIcons: { | ||
time: "fa fa-clock-o", | ||
date: "fa fa-calendar", | ||
up: "fa fa-chevron-up", | ||
down: "fa fa-chevron-down", | ||
previous: "fa fa-angle-double-left", | ||
next: "fa fa-angle-double-right", | ||
close: "fa fa-times" | ||
} | ||
}); |
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,13 @@ | ||
<div class="form-group"> | ||
{{#if label}} | ||
<label>{{label}}</label> | ||
{{/if}} | ||
<div class="form-group"> | ||
{{bs-datetimepicker | ||
date=date | ||
format=format | ||
dateIcon="fa fa-calendar" | ||
icons=calendarIcons | ||
updateDate=(action (mut date))}} | ||
</div> | ||
</div> |
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,64 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
/** | ||
* Type of input | ||
* | ||
* @property type | ||
* @type {String} | ||
* @default text | ||
*/ | ||
type: 'text', | ||
|
||
/** | ||
* Value of the input | ||
* | ||
* @property value | ||
* @type {String} | ||
*/ | ||
|
||
/** | ||
* The form label to display | ||
* | ||
* @property label | ||
* @type {String} | ||
*/ | ||
|
||
/** | ||
* The text to display when empty | ||
* | ||
* @property placeholder | ||
* @type {String} | ||
*/ | ||
|
||
/** | ||
* Whether the value is required | ||
* | ||
* @property required | ||
* @type {Boolean} | ||
* @default false | ||
*/ | ||
required: false, | ||
|
||
/** | ||
* Text to display next to the checkbox | ||
* | ||
* @property text | ||
* @type {String} | ||
*/ | ||
|
||
/** | ||
* Maximum number of characters allowed | ||
* | ||
* @property maxlength | ||
* @type {Number} | ||
*/ | ||
|
||
/** | ||
* Class to set on the input | ||
* | ||
* @property class | ||
* @type {string} | ||
*/ | ||
class: 'form-control' | ||
}); |
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,13 @@ | ||
<div class="form-group"> | ||
{{#if label}} | ||
<label>{{label}}</label> | ||
{{/if}} | ||
{{input | ||
value=value | ||
placeholder=placeholder | ||
required=required | ||
type=type | ||
maxlength=maxlength | ||
class=class}} | ||
{{yield}} | ||
</div> |
Oops, something went wrong.