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

Remove ui-select and use a standard select element #1947

Merged
merged 5 commits into from
Aug 15, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
language: node_js
node_js:
- "5"
- "6"

sudo: false

Expand Down
44 changes: 18 additions & 26 deletions app/components/new-programyear.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
import Ember from 'ember';

const { Component, computed, inject, isBlank } = Ember;
const { service } = inject;
const { Component, isEmpty } = Ember;

export default Component.extend({
classNames: ['resultslist-new'],
classNames: ['new-programyear'],

i18n: service(),
placeholder: computed('i18n.locale', function() {
return this.get('i18n').t('programYears.selectAcademicYear');
}),

selection: null,

selectionCheck() {
const selection = this.get('selection');

return isBlank(selection) ? true : false;
},
selectedYear: null,
availableAcademicYears: null,

actions: {
changeSelection(value) {
this.set('selection', value);
setYear(year) {
this.set('selectedYear', year);
},

save() {
if (this.selectionCheck()) {
return;
this.set('isSaving', true);
let startYear = this.get('selectedYear');
if (isEmpty(startYear)) {
const availableAcademicYears = this.get('availableAcademicYears');
startYear = availableAcademicYears.get('firstObject.value');
}

const startYear = this.get('selection.value');
this.sendAction('save', startYear);
},
if (isEmpty(startYear)) {
return false;
}

cancel() {
this.sendAction('cancel');
}
this.get('save')(parseInt(startYear)).finally(() =>{
this.set('isSaving', false);
});
},
}
});
8 changes: 4 additions & 4 deletions app/components/programyear-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { mapBy, sort } = computed;
const { all } = RSVP;

export default Component.extend({
classNames: ['detail-view', 'programyear-list'],
classNames: ['programyear-list'],

store: service(),
i18n: service(),
Expand Down Expand Up @@ -94,8 +94,8 @@ export default Component.extend({
}));
}

all(promises).then(() => {
newProgramYear.save().then((savedProgramYear) => {
return all(promises).then(() => {
return newProgramYear.save().then((savedProgramYear) => {
const store = component.get('store');
let promises = [];

Expand All @@ -110,7 +110,7 @@ export default Component.extend({

promises.pushObject(cohort.save());

all(promises).then(() => {
return all(promises).then(() => {
component.setProperties({ saved: true, savedProgramYear: newProgramYear });
component.send('cancel');
});
Expand Down
1 change: 0 additions & 1 deletion app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
@import 'components/global-search';
@import 'components/error-display';
@import 'components/mesh-manager';
@import 'components/programyear-list';
@import 'components/validation-error';
@import 'components/detail-learning-materials';
@import 'components/course-objective-manager';
Expand Down
101 changes: 0 additions & 101 deletions app/styles/components/_programyear-list.scss

This file was deleted.

1 change: 1 addition & 0 deletions app/styles/newcomponents.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@
@import 'newcomponents/learnergroup-selection-manager';
@import 'newcomponents/session-copy';
@import 'newcomponents/instructorgroup-header';
@import 'newcomponents/programyear-list';
58 changes: 58 additions & 0 deletions app/styles/newcomponents/programyear-list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.programyear-list {
@include main-list;
//@todo [JRJ 8/2016] this is a fix for mismatching padding between program overview
// and the program year list, it should be removed when the overview is
// fixed to use a new component style.
padding: 0;

.programyears {
@include main-list-box;

.header {
@include main-list-box-header;

h2 {
@include ilios-heading;
}

.title {
@include main-list-box-header-title;
}

.actions {
@include main-list-box-header-actions;
}
}
}

.list {
@include main-list-box-table;
}
}

.new-programyear {
@include fill-parent;
@include clearfix;

margin: 1em 5em;

.title {
@include fill-parent;
@include ilios-heading-h4;

margin: 1em 0;
}

.startyear-select,
.buttons {
float: left;
}

button {
margin-left: .5em;
}

label {
@include ilios-label;
}
}
33 changes: 21 additions & 12 deletions app/templates/components/new-programyear.hbs
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
<div class="new-result-title">{{t 'programYears.new'}}</div>
<h4 class='title'>{{t 'programYears.new'}}</h4>

<div class="programyear-select-container">
<div class="programyear-select">
{{#ui-select showPlaceholderAsOption=false placeholder=placeholder on-select="changeSelection" value=value items=availableAcademicYears as |item|}}
{{#ui-option value=item}}
{{item.label}}
{{/ui-option}}
{{/ui-select}}
<div class='form'>
<div class="startyear-select">
<label>{{t 'general.academicYear'}}:</label>
<select onchange={{action "setYear" value="target.value"}}>
{{#each (sort-by 'value' availableAcademicYears) as |obj|}}
<option value={{obj.value}} selected={{eq obj.value selectedYear}}>
{{obj.label}}
</option>
{{/each}}
</select>
</div>

<span class='programyear-action'>
<button class="programyear-save" title='{{t "general.save"}}' {{action 'save'}}>{{fa-icon 'check'}}</button>
<button class="programyear-cancel" title='{{t "general.cancel"}}' {{action 'cancel'}}>{{fa-icon 'undo'}}</button>
</span>
<div class='buttons'>
<button class='done text' {{action 'save'}}>
{{#if isSaving}}
{{fa-icon 'spinner' spin=true}}
{{else}}
{{t 'general.done'}}
{{/if}}
</button>
<button class='cancel text' {{action cancel}}>{{t 'general.cancel'}}</button>
</div>
</div>
Loading