From de0aff29d129b99ddbbbfa9f7372dc19fd12beb5 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Tue, 21 Mar 2017 18:53:49 -0800 Subject: [PATCH 001/383] Update contact model --- app/app.js | 18 +++ app/models/contact.js | 140 +++++++++++++++--- .../control/md-button-modal/component.js | 2 + 3 files changed, 136 insertions(+), 24 deletions(-) diff --git a/app/app.js b/app/app.js index 4cd3a65ed..e9f7c38c1 100644 --- a/app/app.js +++ b/app/app.js @@ -33,6 +33,15 @@ Ember.Route.reopen({ export default App; +/** +* Models for the mdEditor data store + +* @main data-models +* @module mdeditor +* @submodule data-models +* @category docs +*/ + /** * Components used to create objects or arrays of objects. * @@ -50,3 +59,12 @@ export default App; * @main components-input * @category docs */ + + /** + * Components used as UI controls. + * + * @module mdeditor + * @submodule components-control + * @main components-control + * @category docs + */ diff --git a/app/models/contact.js b/app/models/contact.js index 18c4a3770..dcf30064a 100644 --- a/app/models/contact.js +++ b/app/models/contact.js @@ -4,62 +4,143 @@ import uuidV4 from 'npm:uuid/v4'; import Validator from 'npm:validator'; export default DS.Model.extend(Ember.Copyable, { + /** + * Contact model + * + * @class contact + * @constructor + * @extends DS.Model + * @mixin Ember.Copyable + * @module mdeditor + * @submodule data-models + */ + + /** + * The json object for the contact. The data for the contact is stored in this + * object. + * + * @attribute json + * @type {json} + * @required + */ json: DS.attr('json', { defaultValue: function () { let obj = Ember.Object.create({ 'contactId': uuidV4(), - 'organizationName': null, - 'individualName': null, + 'isOrganization': false, + 'name': null, 'positionName': null, - 'phoneBook': [], - 'address': {}, + 'memberOfOrganization': [], + 'logoGraphic': [], + 'phone': [], + 'address': [], + 'electronicMailAddress': [], 'onlineResource': [], - 'contactInstructions': null + 'hoursOfService': [], + 'contactInstructions': null, + 'contactType': null }); return obj; } }), + + /** + * The timestamp for the record + * + * @attribute dateUpdated + * @type {date} + * @default new Date() + * @required + */ dateUpdated: DS.attr('date', { defaultValue() { return new Date(); } }), - title: Ember.computed('json.individualName', 'json.organizationName', + /** + * The formatted display string for the contact + * + * @property title + * @type {String} + * @readOnly + * @category computed + * @requires json.name, json.positionName + */ + title: Ember.computed('json.name', 'json.positionName', function () { const json = this.get('json'); - return json.individualName || json.organizationName; + return json.individualName || json.positionName; }), - icon: Ember.computed('json.individualName', 'json.organizationName', + /** + * The display icon for the contact + * + * @property icon + * @type {String} + * @readOnly + * @category computed + * @requires json.isOrganization + */ + icon: Ember.computed('json.isOrganization', function () { - const name = this.get('json.individualName'); + const name = this.get('json.isOrganization'); - return name ? 'user' : 'users'; + return name ? 'users' : 'user'; }), - combinedName: Ember.computed('json.individualName', - 'json.organizationName', + /** + * The formatted (name or position) and organization(if any) of the contact. + * + * @property combinedName + * @type {String} + * @readOnly + * @category computed + * @requires json.name, json.isOrganization + */ + combinedName: Ember.computed('json.name', 'json.isOrganization', + 'json.positionName', function () { const json = this.get('json'); - let indName = json.individualName; - let orgName = json.organizationName; - let combinedName = orgName; - - if(indName && orgName) { - return combinedName += ": " + indName; + let { + name, + positionName, + isOrganization, + memberOfOrganization + } = json; + + let orgId = memberOfOrganization.length ? memberOfOrganization[0] : + null; + let combinedName = name || positionName; + let orgName; + + if(orgId) { + this.get('store') + .findRecord('contact', orgId) + .then(function (org) { + orgName = org.name; + }); } - if(indName) { - return combinedName = indName; + if(orgName && !isOrganization) { + return combinedName += ": " + combinedName; } return combinedName; }), + /** + * The trimmed varsion of the contactId. + * + * @property shortId + * @type {String} + * @readOnly + * @category computed + * @requires json.contactId + */ shortId: Ember.computed('json.contactId', function () { const contactId = this.get('json.contactId'); if(contactId && Validator.isUUID(contactId)) { @@ -69,15 +150,26 @@ export default DS.Model.extend(Ember.Copyable, { return contactId; }), + /** + * Create a copy of the record in the store. + * + * @method copy + * @chainable + * @return {DS.Model} + */ copy() { let current = this.get('json'); let json = Ember.Object.create(JSON.parse(JSON.stringify(current))); - let indName = current.individualName; - let orgName = current.organizationName; + let { + name, + positionName, + isOrganization + } = current; json.setProperties({ - organizationName: indName ? orgName : `Copy of ${orgName}`, - individualName: indName ? `Copy of ${indName}` : null, + isOrganization: isOrganization, + name: name ? `Copy of ${name}` : null, + positionName: name ? positionName : `Copy of ${positionName}`, contactId: uuidV4() }); diff --git a/app/pods/components/control/md-button-modal/component.js b/app/pods/components/control/md-button-modal/component.js index 147bf913f..d40999f88 100644 --- a/app/pods/components/control/md-button-modal/component.js +++ b/app/pods/components/control/md-button-modal/component.js @@ -6,6 +6,8 @@ export default Ember.Component.extend({ * dialog when clicked. * * @class md-button-modal + * @module mdeditor + * @submodule components-control * @constructor */ From d060ff15118146d59624ea73735130f0732778ba Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Mon, 27 Mar 2017 07:45:44 -0800 Subject: [PATCH 002/383] Add md-array-table --- .../object/md-array-table/component.js | 192 ++++++++++++++++++ .../object/md-array-table/template.hbs | 58 ++++++ .../object/md-array-table/component-test.js | 25 +++ 3 files changed, 275 insertions(+) create mode 100644 app/pods/components/object/md-array-table/component.js create mode 100644 app/pods/components/object/md-array-table/template.hbs create mode 100644 tests/integration/pods/components/object/md-array-table/component-test.js diff --git a/app/pods/components/object/md-array-table/component.js b/app/pods/components/object/md-array-table/component.js new file mode 100644 index 000000000..c3e5b35c7 --- /dev/null +++ b/app/pods/components/object/md-array-table/component.js @@ -0,0 +1,192 @@ +import Ember from 'ember'; + +const { + computed, + Component, + A, + typeOf +} = Ember; + +export default Component.extend({ + init(){ + this._super(...arguments); + this.set('value', A(this.get('value'))) + }, + /** + * mdEditor class for input and edit of arrays of objects or scalars. The + * component is rendered as an editable table. + * + * @class md-array-table + * @submodule components-object + * @constructor + */ + + /** + * The array to render in the template + * + * @property value + * @type {Array} + * @default Ember.A() + * @required + */ + value: A(), + + /** + * The template class to use for new items. This should be a constructor. + * Objects should be created by extending Ember.Object. + * ```javascript + * Ember.Object.extend({ + * foo: null, + * bar: Ember.A() + * } + * ``` + * + * @property templateClass + * @type {Any} + * @constructor + * @default String + * @required + */ + templateClass: String, + + /** + * Comma-separated list of column headers to display in the table. If not + * provided, the table header will not be created. + * + * @property columns + * @type String + */ + + /** + * Inital collapse staet fo the panel. + * + * @property isCollapsed + * @type {Boolean} + * @default undefined + */ + + /** + * Indicates whether at least one item is required is required in the value + * array. + * + * @property required + * @type {Boolean} + * @default false + */ + required: false, + + /** + * The title for the panel. Should be in singular form. + * + * @property title + * @type {String} + * @default Item + */ + title: 'Item', + + /** + * Array of column headers + * + * @property columnArray + * @type {Array} + * @readOnly + * @category computed + * @requires columns + */ + columnArray: Ember.computed('columns', function () { + let columns = this.get('columns'); + + return(typeof columns === 'string') ? columns.split(',') : null; + }), + + /** + * Uses isCollapsed if defined, otherwise inspects array length. + * + * @property collapsed + * @type {Boolean} + * @readOnly + * @category computed + * @requires isCollapsed + */ + collapsed: Ember.computed('isCollapsed', function () { + let isCollapsed = this.get('isCollapsed'); + + if(isCollapsed !== undefined) { + return isCollapsed; + } else if(this.get('value') + .length > 0) { + return false; + } else { + return true; + } + }), + + /** + * The panel id selector + * + * @property panelId + * @type {String} + * @default "panel-{this.elementId}" + * @readOnly + * @category computed + * @requires elementId + */ + panelId: computed('elementId', function () { + return 'panel-' + this.get('elementId'); + }), + + /** + * The color of the counter displayed in the panel header + * + * @property pillColor + * @type {String} + * @readOnly + * @category computed + * @requires value.[] + */ + pillColor: Ember.computed('value.[]', function () { + let count = this.get('value') + .length; + let required = this.get('required'); + return(count === 0) ? required ? 'label-danger' : 'label-warning' : + 'label-info'; + }), + + /** + * Focus the added row, or the last row on deletion. + * + * @method valueChanged + * @return none + */ + valueChanged() { + Ember.run.schedule('afterRender', this, function () { + let panel = this.$('.panel-collapse'); + let input = this.$('.panel-collapse tbody tr:last-of-type input') + .first(); + + if(panel.hasClass('in')) { + input.focus(); + } else { //add a one-time listener to wait until panel is open + panel.one('shown.bs.collapse', function () { + input.focus(); + }); + panel.collapse('show'); + } + }); + }, + + actions: { + addItem: function (value) { + const Template = this.get('templateClass'); + + value.pushObject(typeOf(Template) === 'class' ? Template.create() : + new Template()); + this.valueChanged(); + }, + + deleteItem: function (value, idx) { + value.removeAt(idx); + this.valueChanged(); + } + } +}); diff --git a/app/pods/components/object/md-array-table/template.hbs b/app/pods/components/object/md-array-table/template.hbs new file mode 100644 index 000000000..0b91fa408 --- /dev/null +++ b/app/pods/components/object/md-array-table/template.hbs @@ -0,0 +1,58 @@ +
+ + + + + +
diff --git a/tests/integration/pods/components/object/md-array-table/component-test.js b/tests/integration/pods/components/object/md-array-table/component-test.js new file mode 100644 index 000000000..1b462f714 --- /dev/null +++ b/tests/integration/pods/components/object/md-array-table/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('object/md-array-table', 'Integration | Component | object/md array table', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{object/md-array-table}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#object/md-array-table}} + template block text + {{/object/md-array-table}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); From 09d7d47821a5dae43548a949bb4d2f5e6a3c2dc5 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Mon, 27 Mar 2017 07:45:56 -0800 Subject: [PATCH 003/383] Add md-toggle --- .../components/input/md-toggle/component.js | 24 +++++++++++ app/styles/_toggle.scss | 42 ++++++++++++++++--- .../input/md-toggle/component-test.js | 25 +++++++++++ 3 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 app/pods/components/input/md-toggle/component.js create mode 100644 tests/integration/pods/components/input/md-toggle/component-test.js diff --git a/app/pods/components/input/md-toggle/component.js b/app/pods/components/input/md-toggle/component.js new file mode 100644 index 000000000..5e695396d --- /dev/null +++ b/app/pods/components/input/md-toggle/component.js @@ -0,0 +1,24 @@ +import Toggle from 'ember-toggle/components/x-toggle/component'; + +export default Toggle.extend({ + /** + * Custom toggle switch for boolean input + * + * @class md-toggle + * @constructor + * @extends ember-toggle/components/x-toggle + * @module mdeditor + * @submodule components-input + */ + + /** + * Bound classes: + * - value + * - __true__: toggle-on + * - __false__: toggle-off + * + * @property classNameBindings + * @type {Array} + */ + classNameBindings: ['value:toggle-on:toggle-off'] +}); diff --git a/app/styles/_toggle.scss b/app/styles/_toggle.scss index 83c06b53e..62b66f6ac 100644 --- a/app/styles/_toggle.scss +++ b/app/styles/_toggle.scss @@ -1,33 +1,63 @@ -.x-toggle-default.x-toggle-btn { +.x-toggle-default.x-toggle-btn, +.x-toggle-form.x-toggle-btn { background-color: $btn-danger-bg; border-radius: .2em; padding: .16em .1em; transition: background-color .2s; } -.x-toggle:checked + .x-toggle-default.x-toggle-btn { +.x-toggle-form.x-toggle-btn { + background-color: $btn-primary-bg; +} + +.x-toggle:checked + .x-toggle-default.x-toggle-btn, +.x-toggle:checked + .x-toggle-form.x-toggle-btn { background-color: $btn-success-bg; } -.x-toggle-default.x-toggle-btn::after { +.x-toggle-default.x-toggle-btn::after, +.x-toggle-form.x-toggle-btn::after { background-color: $body-bg; border-radius: .2em; transition: left .2s; } -.x-toggle-default.small { +.x-toggle-btn.small { height: 1.6em; width: 3em; } -.x-toggle-default.medium { +.x-toggle-btn.medium { height: 2.1em; padding: 3px; width: 4em; } -.x-toggle-default.large { +.x-toggle-btn.large { height: 2.1em; padding: 4px; width: 4.7em; } + +.form-group { + .x-toggle-component { + .toggle-text { + font-weight: 500; + } + + &.toggle-on { + .on-label { + color: $btn-success-bg; + text-decoration: underline; + } + } + + &.toggle-off { + .off-label { + color: $btn-primary-bg; + text-decoration: underline; + } + } + + } +} diff --git a/tests/integration/pods/components/input/md-toggle/component-test.js b/tests/integration/pods/components/input/md-toggle/component-test.js new file mode 100644 index 000000000..3cee5deb7 --- /dev/null +++ b/tests/integration/pods/components/input/md-toggle/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('input/md-toggle', 'Integration | Component | input/md toggle', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{input/md-toggle}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#input/md-toggle}} + template block text + {{/input/md-toggle}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); From 233fe43d3fe12ac32534de6d9483b03f0d0c94cf Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Mon, 27 Mar 2017 07:47:09 -0800 Subject: [PATCH 004/383] Update contact templates --- app/helpers/add-em.js | 4 +- app/models/contact.js | 17 ++- .../object/md-phone-array/component.js | 118 ++---------------- .../object/md-phone-array/template.hbs | 100 ++++----------- app/pods/contact/new/id/route.js | 97 ++++++++++---- app/pods/contact/new/id/template.hbs | 40 ++++-- app/pods/contact/show/edit/template.hbs | 33 +++-- app/styles/_typography.scss | 4 + 8 files changed, 182 insertions(+), 231 deletions(-) diff --git a/app/helpers/add-em.js b/app/helpers/add-em.js index d841495e1..8b4e06737 100644 --- a/app/helpers/add-em.js +++ b/app/helpers/add-em.js @@ -1,9 +1,7 @@ import Ember from 'ember'; export function addEm(params) { - return params.reduce(function (a, b) { - return a + b; - }); + return params.reduce((a, b) => Number(a) + Number(b)); } export default Ember.Helper.helper(addEm); diff --git a/app/models/contact.js b/app/models/contact.js index dcf30064a..e2440c7bb 100644 --- a/app/models/contact.js +++ b/app/models/contact.js @@ -72,7 +72,22 @@ export default DS.Model.extend(Ember.Copyable, { function () { const json = this.get('json'); - return json.individualName || json.positionName; + return json.name || (json.isOrganization ? null : json.positionName); + }), + + /** + * The type of contact + * + * @property type + * @type {String} + * @readOnly + * @category computed + * @requires json.isOrganization + */ + type: Ember.computed('json.isOrganization', + function () { + return this.get('json.isOrganization') ? 'Organization' : + 'Individual'; }), /** diff --git a/app/pods/components/object/md-phone-array/component.js b/app/pods/components/object/md-phone-array/component.js index eb2308654..59c348688 100644 --- a/app/pods/components/object/md-phone-array/component.js +++ b/app/pods/components/object/md-phone-array/component.js @@ -1,9 +1,9 @@ -/** - * @module mdeditor - */ - import Ember from 'ember'; +const { + Object: EmObject +} = Ember; + export default Ember.Component.extend({ /** @@ -11,113 +11,21 @@ export default Ember.Component.extend({ * The class manages the maintenance of an array of phone objects. * * @class md-phone-array + * @module mdeditor * @submodule components-object * @constructor */ /** - * An array of mdJSON phone objects. + * See [md-array-table](md-array-table.html#property_templateClass). * - * @property phoneBook - * @type Array - * @required + * @property templateClass + * @type Ember.Object */ - - /** - * Indicates the initial panel collapsed state. - * - * @property isCollapsed - * @type Boolean - */ - - mdCodes: Ember.inject.service('codelist'), - phoneServices: Ember.computed(function () { - let mdCodelist = this.get('mdCodes') - .get('telephone') - .codelist; - let serviceType = []; - mdCodelist.forEach(function (telephone) { - serviceType.push(telephone['codeName']); - }); - return serviceType; - }), - - //is this neccessary? Can this be used instead: $(this)[0].get('elementId') - //or just this.$('.panel-collapse') if you just need to add a listener to - //the show.bs.* events - panelId: Ember.computed(function () { - return Ember.generateGuid(null, 'panel'); - }), - - //uses isCollapsed if defined, otherwise inspects array length - collapsed: Ember.computed('isCollapsed', function () { - let isCollapsed = this.get('isCollapsed'); - - if(isCollapsed !== undefined) { - return isCollapsed; - } else if(this.get('phoneBook') - .length > 0) { - return false; - } else { - return true; - } - }), - - //focus the added row, or the last row on deletion - phoneBookChanged() { - //https://guides.emberjs.com/v2.6.0/applications/run-loop/ - Ember.run.schedule('afterRender', this, function () { - let panel = this.$('.panel-collapse'); - let input = this.$('.panel-collapse tbody tr:last-of-type input') - .first(); - - if(panel.hasClass('in')) { - input.focus(); - } else { //add a one-time listener to wait until panel is open - panel.one('shown.bs.collapse', function () { - input.focus(); - }); - panel.collapse('show'); - } - }); - }, - - pillColor: Ember.computed('phoneBook.[]', function () { - let count = this.get('phoneBook') - .length; - return(count > 0) ? 'label-info' : 'label-warning'; - }), - - /*didInsertElement: function () { - let panel = this.get('panelId'); - let panelBtn = panel + '-btn'; - - $('#' + panel) - .on('show.bs.collapse', function () { - $('#' + panelBtn) - .removeClass('invisible'); - }); - $('#' + panel) - .on('hidden.bs.collapse', function () { - $('#' + panelBtn) - .addClass('invisible'); - }); - },*/ - - actions: { - addPhone: function (phoneBook) { - phoneBook.pushObject(Ember.Object.create({ - phoneName: "", - phoneNumber: "", - service: [] - })); - this.phoneBookChanged(); - }, - - deletePhone: function (phoneBook, idx) { - phoneBook.removeAt(idx); - this.phoneBookChanged(); - } - } + templateClass: EmObject.extend({ + phoneName: null, + phoneNumber: null, + service: [] + }) }); diff --git a/app/pods/components/object/md-phone-array/template.hbs b/app/pods/components/object/md-phone-array/template.hbs index ebfa5c05c..f3fc049da 100644 --- a/app/pods/components/object/md-phone-array/template.hbs +++ b/app/pods/components/object/md-phone-array/template.hbs @@ -1,75 +1,25 @@ -
- - - - - -
+{{#object/md-array-table + columns="Name,Number,Services" + title="Phone" + value=value + templateClass=templateClass as |phone| +}} + + {{input/md-input value=phone.item.phoneName + placeholder="Name or location or phone"}} + + + {{input/md-input value=phone.item.phoneNumber + placeholder="Phone number"}} + + + {{input/md-codelist-multi + create=true + tooltip=true + icon=false + disabled=disabled + allowClear=true + mdCodeName="telephone" + value=phone.item.service placeholder="Choose phone type" }} + +{{/object/md-array-table}} diff --git a/app/pods/contact/new/id/route.js b/app/pods/contact/new/id/route.js index a9296db68..795153e53 100644 --- a/app/pods/contact/new/id/route.js +++ b/app/pods/contact/new/id/route.js @@ -1,16 +1,44 @@ import Ember from 'ember'; +import DS from 'ember-data'; + +const { + AdapterError +} = DS; export default Ember.Route.extend({ + /** + * The route model + * + * @method model + * @param {Object} params + * @chainable + * @return {Object} + */ model: function (params) { - // if(!params.contact_id) { - // return this.store.createRecord('contact'); - // } + let record = this.store.peekRecord('contact', params.contact_id); + + if(record) { + return record; + } return this.store.findRecord('contact', params.contact_id); }, + /** + * The breadcrumb title string. + * + * @property breadCrumb + * @type {String} + * @default null + */ breadCrumb: null, + /** + * Called when route is deactivated. + * The model is destroyed if still "new". + * + * @method deactivate + */ deactivate: function () { // We grab the model loaded in this route var model = this.currentModel; @@ -23,27 +51,26 @@ export default Ember.Route.extend({ } }, - //some test actions setupController: function (controller, model) { // Call _super for default behavior this._super(controller, model); - // setup tests for required attributes - controller.noId = Ember.computed('model.json.contactId', function () { - return model.get('json.contactId') ? false : true; - }); - controller.noName = Ember.computed('model.json.individualName', - 'model.json.organizationName', - function () { - let haveIndividual = model.get('json.individualName') ? true : - false; - let haveOrganization = model.get('json.organizationName') ? - true : false; - return !(haveIndividual || haveOrganization); - }); - controller.allowSave = Ember.computed('noId', 'noName', function () { - return(this.get('noName') || this.get('noId')); - }); + // // setup tests for required attributes + // controller.noId = Ember.computed('model.json.contactId', function () { + // return model.get('json.contactId') ? false : true; + // }); + // controller.noName = Ember.computed('model.json.individualName', + // 'model.json.organizationName', + // function () { + // let haveIndividual = model.get('json.individualName') ? true : + // false; + // let haveOrganization = model.get('json.organizationName') ? + // true : false; + // return !(haveIndividual || haveOrganization); + // }); + // controller.allowSave = Ember.computed('noId', 'noName', function () { + // return(this.get('noName') || this.get('noId')); + // }); }, // serialize: function (model) { @@ -61,9 +88,21 @@ export default Ember.Route.extend({ actions: { willTransition: function (transition) { - if (transition.targetName === 'contact.new.index') { - this.currentModel.destroyRecord(); - return true; + if(transition.targetName === 'contact.new.index') { + transition.abort(); + return true; + } + + // We grab the model loaded in this route + var model = this.currentModel; + // If we are leaving the Route we verify if the model is in + // 'isNew' state, which means it wasn't saved to the backend. + if(model && model.get('isNew')) { + // We call DS#destroyRecord() which removes it from the store + model.destroyRecord(); + transition.abort(); + this.replaceWith(transition.targetName); + return true; } }, @@ -79,6 +118,18 @@ export default Ember.Route.extend({ this.replaceWith('contacts'); return false; + }, + + error(error) { + if(error instanceof AdapterError) { + Ember.get(this, 'flashMessages') + .warning('No contact found! Re-directing to new contact...'); + // redirect to new + this.replaceWith('contact.new'); + } else { + // otherwise let the error bubble + return true; + } } } }); diff --git a/app/pods/contact/new/id/template.hbs b/app/pods/contact/new/id/template.hbs index 6b1ffec3a..8a6014305 100644 --- a/app/pods/contact/new/id/template.hbs +++ b/app/pods/contact/new/id/template.hbs @@ -1,12 +1,10 @@ -
-
+ -
+{{!--
{{#if noId}} {{/if}}
-
+
--}}
+
+ +
+ {{input/md-toggle + value=model.json.isOrganization + onToggle=(mut model.json.isOrganization) + showLabels=true + onLabel="Organization::true" + offLabel="Individual::false" + size="large" + theme="form" + }} +
+
@@ -32,21 +44,23 @@
- +
{{input/md-input - value=model.json.individualName - placeholder="Enter a name for this person"}} + value=model.json.name + placeholder="Enter a name for this contact"}}
-
- + {{#unless model.json.isOrganization}} +
+
{{input/md-input - value=model.json.organizationName - placeholder="Enter a name for this organization"}} + value=model.json.positionName + placeholder="Enter a name for this position"}}
+ {{/unless}}
diff --git a/app/pods/contact/show/edit/template.hbs b/app/pods/contact/show/edit/template.hbs index 1b2e97dbe..ae92742b9 100644 --- a/app/pods/contact/show/edit/template.hbs +++ b/app/pods/contact/show/edit/template.hbs @@ -1,24 +1,35 @@ +
- -

Editing Contact: {{model.json.contactId}}

-
{{input/md-input value=model.json.contactId placeholder="User assigned Contact ID" label="Contact ID"}} - {{input/md-input value=model.json.organizationName - placeholder="Organization Name" label="Organization Name"}} - - {{input/md-input value=model.json.individualName - placeholder="Individual Name" label="Individual Name"}} + {{input/md-input value=model.json.name + placeholder=(concat model.type " Name") label=(concat model.type " Name")}} {{input/md-input value=model.json.positionName - placeholder="If Individual Name, provide Position" label="Position Name"}} + placeholder="Position Name" label="Position Name"}} - {{object/md-phone-array phoneBook=model.json.phoneBook isCollapsed=false}} + {{object/md-phone-array value=model.json.phone isCollapsed=false}} + + {{#object/md-array-table + columns="E-mail" + title="E-mail Address" + required=true + value=model.json.electronicMailAddress as |email| + }} + + {{input/md-input value=email.item + placeholder="Enter valid e-mail address"}} + + {{/object/md-array-table}} - {{object/md-address address=model.json.address}} + {{!-- {{object/md-address address=model.json.address}} --}} {{object/md-online-resource-array model=model.json}} diff --git a/app/styles/_typography.scss b/app/styles/_typography.scss index e65770ff8..cf48e1dec 100644 --- a/app/styles/_typography.scss +++ b/app/styles/_typography.scss @@ -2,3 +2,7 @@ padding-left: .3em; padding-right: .3em; } + +.page-header { + margin: 20px 0; +} From e326029da5166317971339b6044b34a2619b2437 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Mon, 27 Mar 2017 07:47:21 -0800 Subject: [PATCH 005/383] Update packages --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 898a27d85..6a3ca44ca 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "ember-leaflet-layer-control": "0.0.1", "ember-load": "~0.0.9", "ember-load-initializers": "^0.6.0", - "ember-local-storage": "1.3.3", + "ember-local-storage": "^1.3.6", "ember-modal-dialog": "^0.9.0", "ember-models-table": "1.11.0", "ember-multiselect-checkboxes": "^0.10.2", @@ -85,7 +85,7 @@ "geojson-coords": "0.0.0", "loader.js": "^4.0.10", "lodash": "^4.17.4", - "mdcodes": "^2.0.0", + "mdcodes": "^2.1.5", "shapefile": "^0.6.2", "uuid": "^3.0.1", "validator": "^6.2.0", From 700b5d559d53c204fb063b3d39a06333d51a4ce5 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Mon, 27 Mar 2017 17:02:40 -0800 Subject: [PATCH 006/383] Update contact components, add simple-array-table --- .../components/object/md-address/component.js | 86 +++++++++-------- .../components/object/md-address/template.hbs | 92 ++++++++++--------- .../object/md-array-table/component.js | 53 +++++++---- .../object/md-array-table/template.hbs | 2 +- .../object/md-object-table/template.hbs | 8 +- .../md-online-resource-array/component.js | 20 +--- .../md-online-resource-array/template.hbs | 12 +-- .../object/md-simple-array-table/component.js | 67 ++++++++++++++ app/pods/contact/show/edit/template.hbs | 16 ++-- .../md-simple-array-table/component-test.js | 25 +++++ 10 files changed, 239 insertions(+), 142 deletions(-) create mode 100644 app/pods/components/object/md-simple-array-table/component.js create mode 100644 tests/integration/pods/components/object/md-simple-array-table/component-test.js diff --git a/app/pods/components/object/md-address/component.js b/app/pods/components/object/md-address/component.js index 7e557e5b5..c184acad2 100644 --- a/app/pods/components/object/md-address/component.js +++ b/app/pods/components/object/md-address/component.js @@ -1,49 +1,47 @@ -/** - * @module mdeditor - * @submodule components-object - */ - import Ember from 'ember'; export default Ember.Component.extend({ - - /** - * mdEditor class for input and edit of mdJSON address objects. - * - * @class md-address - * @constructor - */ - - /** - * mdJSON 'address' object to be edited. - * - * @property address - * @type Object - * @required - */ - - panelId: Ember.computed(function () { - return Ember.generateGuid(null, 'panel'); - }), - - /** - * Indicate whether the address object is not empty. - * - * @property isEmpty - * @type Boolean - */ - - notEmpty: Ember.computed('address', 'address.city', - 'address.deliveryPoint', 'address.adminsitrativeArea', - 'address.postalCode', 'address.country', - 'address.electronicMailAddress.[]', - function () { - let address = this.get('address'); - let keys = Object.keys(address); - - return keys.some(function (key) { - return !Ember.isEmpty(address[key]); - }); - }) + /** + * mdEditor class for input and edit of mdJSON 'address' object + * arrays. The class manages the maintenance of an array of address + * objects using the md-object-table class. + * + * @module mdeditor + * @submodule components-object + * @class md-address + * @constructor + * @requires md-object-table + */ + + /** + * mdJSON object containing the 'address' array. + * + * @property model + * @type Object + * @required + */ + + /** + * List of mdJSON 'address' object attributes to display in + * md-object-table to aid in choosing the address to edit or + * delete. + * The property is passed to md-object-table for configuration. + * + * @property attributes + * @type String + * @default 'name, uri' + */ + attributes: 'deliveryPoint.0,city', + + /** + * Name to place on the mdEditor panel header for entry and edit of + * 'address' objects. + * The property is passed to md-object-table for configuration. + * + * @property label + * @type String + * @default 'Address' + */ + label: 'Address' }); diff --git a/app/pods/components/object/md-address/template.hbs b/app/pods/components/object/md-address/template.hbs index c4ca8ac9e..5dffcdd2b 100644 --- a/app/pods/components/object/md-address/template.hbs +++ b/app/pods/components/object/md-address/template.hbs @@ -1,49 +1,51 @@ -
- -
-

- -

+
+ + {{#object/md-object-table + items=model.address + header=label + buttonText="Add Address" + attributes=attributes as |address| + }} + + Editing: {{address.name}} + + {{!-- {{input/md-inputs model=address.deliveryPoint + placeholder="Address line" label="Address Lines" + buttonText="Add Line"}} --}} +{{!-- + {{#object/md-simple-array-table + columns="Street" + title="Street" + required=true + value=address.deliveryPoint as |line| + }} + + {{input/md-input value=line.item.value + placeholder="Enter street address"}} + + {{/object/md-simple-array-table}} --}} + + {{input/md-input value=address.city + placeholder="City Name" label="City"}} + + {{input/md-input value=address.adminsitrativeArea + placeholder="State or Province" label="State/Province"}} + + {{input/md-input value=address.postalCode + placeholder="Zip or Postal Code" label="Postal Code"}} + + {{input/md-input value=address.country + placeholder="Country Name" label="Country"}} + +
+ {{input/md-codelist + value=address.country + width="175px" + create=true tooltip=true icon=false mdCodeName="countries" + placeholder="Enter a country code"}}
-
-
- {{input/md-inputs model=address.deliveryPoint - placeholder="Address line" label="Address Lines" - buttonText="Add Line"}} - - {{input/md-input value=address.city - placeholder="City Name" label="City"}} - - {{input/md-input value=address.adminsitrativeArea - placeholder="State or Province" label="State/Province"}} - - {{input/md-input value=address.postalCode - placeholder="Zip or Postal Code" label="Postal Code"}} - - {{input/md-input value=address.country - placeholder="Country Name" label="Country"}} - -
- {{input/md-codelist - value=address.country - width="175px" - create=true tooltip=true icon=false mdCodeName="country" - placeholder="Enter a country code"}} -
- - {{input/md-inputs model=address.electronicMailAddress - placeholder="Email Address" label="Email Addresses" - buttonText="Add Email"}} - -
-
-
+ {{/object/md-object-table}} + {{yield}}
diff --git a/app/pods/components/object/md-array-table/component.js b/app/pods/components/object/md-array-table/component.js index c3e5b35c7..59f642f42 100644 --- a/app/pods/components/object/md-array-table/component.js +++ b/app/pods/components/object/md-array-table/component.js @@ -8,12 +8,8 @@ const { } = Ember; export default Component.extend({ - init(){ - this._super(...arguments); - this.set('value', A(this.get('value'))) - }, /** - * mdEditor class for input and edit of arrays of objects or scalars. The + * mdEditor class for input and edit of arrays of objects. The * component is rendered as an editable table. * * @class md-array-table @@ -21,6 +17,14 @@ export default Component.extend({ * @constructor */ + init() { + this._super(...arguments); + + if (!this.get('value')) { + this.set('value', A()); + } + }, + /** * The array to render in the template * @@ -29,7 +33,7 @@ export default Component.extend({ * @default Ember.A() * @required */ - value: A(), + value: [], /** * The template class to use for new items. This should be a constructor. @@ -93,10 +97,10 @@ export default Component.extend({ * @category computed * @requires columns */ - columnArray: Ember.computed('columns', function () { + columnArray: computed('columns', function() { let columns = this.get('columns'); - return(typeof columns === 'string') ? columns.split(',') : null; + return (typeof columns === 'string') ? columns.split(',') : null; }), /** @@ -108,12 +112,12 @@ export default Component.extend({ * @category computed * @requires isCollapsed */ - collapsed: Ember.computed('isCollapsed', function () { + collapsed: computed('isCollapsed', function() { let isCollapsed = this.get('isCollapsed'); - if(isCollapsed !== undefined) { + if (isCollapsed !== undefined) { return isCollapsed; - } else if(this.get('value') + } else if (this.get('value') .length > 0) { return false; } else { @@ -121,6 +125,17 @@ export default Component.extend({ } }), + /** + * Alias for values + * + * @property arrayValues + * @type {Array} + * @readOnly + * @category computed + * @requires value + */ + arrayValues: computed.alias('value'), + /** * The panel id selector * @@ -131,7 +146,7 @@ export default Component.extend({ * @category computed * @requires elementId */ - panelId: computed('elementId', function () { + panelId: computed('elementId', function() { return 'panel-' + this.get('elementId'); }), @@ -144,11 +159,11 @@ export default Component.extend({ * @category computed * @requires value.[] */ - pillColor: Ember.computed('value.[]', function () { + pillColor: computed('value.[]', function() { let count = this.get('value') .length; let required = this.get('required'); - return(count === 0) ? required ? 'label-danger' : 'label-warning' : + return (count === 0) ? required ? 'label-danger' : 'label-warning' : 'label-info'; }), @@ -159,15 +174,15 @@ export default Component.extend({ * @return none */ valueChanged() { - Ember.run.schedule('afterRender', this, function () { + Ember.run.schedule('afterRender', this, function() { let panel = this.$('.panel-collapse'); let input = this.$('.panel-collapse tbody tr:last-of-type input') .first(); - if(panel.hasClass('in')) { + if (panel.hasClass('in')) { input.focus(); } else { //add a one-time listener to wait until panel is open - panel.one('shown.bs.collapse', function () { + panel.one('shown.bs.collapse', function() { input.focus(); }); panel.collapse('show'); @@ -176,7 +191,7 @@ export default Component.extend({ }, actions: { - addItem: function (value) { + addItem: function(value) { const Template = this.get('templateClass'); value.pushObject(typeOf(Template) === 'class' ? Template.create() : @@ -184,7 +199,7 @@ export default Component.extend({ this.valueChanged(); }, - deleteItem: function (value, idx) { + deleteItem: function(value, idx) { value.removeAt(idx); this.valueChanged(); } diff --git a/app/pods/components/object/md-array-table/template.hbs b/app/pods/components/object/md-array-table/template.hbs index 0b91fa408..4e2702872 100644 --- a/app/pods/components/object/md-array-table/template.hbs +++ b/app/pods/components/object/md-array-table/template.hbs @@ -28,7 +28,7 @@ {{/if}} - {{#each value as |item index|}} + {{#each arrayValues as |item index|}} {{index}} {{yield (hash item=item index=index)}} diff --git a/app/pods/components/object/md-object-table/template.hbs b/app/pods/components/object/md-object-table/template.hbs index d12b496fc..e47366483 100644 --- a/app/pods/components/object/md-object-table/template.hbs +++ b/app/pods/components/object/md-object-table/template.hbs @@ -27,7 +27,7 @@ - {{#each citems key="@index" as |item index|}} + {{#each citems as |item index|}} {{index}} {{#each attrArray as |prop|}} @@ -56,7 +56,11 @@
- {{yield saveItem (action "cancelEdit")}} + {{yield saveItem}} +
+
diff --git a/app/pods/components/object/md-online-resource-array/component.js b/app/pods/components/object/md-online-resource-array/component.js index 70e1ad292..5bc3331e0 100644 --- a/app/pods/components/object/md-online-resource-array/component.js +++ b/app/pods/components/object/md-online-resource-array/component.js @@ -25,17 +25,6 @@ export default Ember.Component.extend({ * @required */ - /** - * Name of the mdJSON 'onlineResource' array in the 'contact' object. - * The property is used to compute items2 which is passed to - * md-object-table for configuration. - * - * @property propertyArrayName - * @type String - * @default 'onlineResource' - */ - //propertyArrayName: 'onlineResource', - /** * List of mdJSON 'onlineResource' object attributes to display in * md-object-table to aid in choosing the onlineResource to edit or @@ -57,12 +46,5 @@ export default Ember.Component.extend({ * @type String * @default 'Online Resource' */ - label: 'Online Resource', - - /*items2: Ember.computed('model', function() { - if (this.get('model.' + this.get('propertyArrayName')) === undefined) { - this.set('model.' + this.get('propertyArrayName'), []); - } - return this.get('model.' + this.get('propertyArrayName')); - })*/ + label: 'Online Resource' }); diff --git a/app/pods/components/object/md-online-resource-array/template.hbs b/app/pods/components/object/md-online-resource-array/template.hbs index 9676a09aa..2b04d057a 100644 --- a/app/pods/components/object/md-online-resource-array/template.hbs +++ b/app/pods/components/object/md-online-resource-array/template.hbs @@ -1,6 +1,11 @@
- {{#object/md-object-table items=model.onlineResource header=label buttonText="Add Resource" attributes=attributes as |editing cancelEdit|}} + {{#object/md-object-table + items=model.onlineResource + header=label + buttonText="Add Resource" + attributes=attributes as |editing| + }} Editing: {{editing.name}} {{input/md-input value=editing.name label="Name" placeholder="Online Resource Name"}} @@ -17,11 +22,6 @@ label="Function" placeholder="Select function of the Online Resource" tooltip=true allowClear=true width="70%"}} -
- - {{/object/md-object-table}} {{yield}} diff --git a/app/pods/components/object/md-simple-array-table/component.js b/app/pods/components/object/md-simple-array-table/component.js new file mode 100644 index 000000000..108f83344 --- /dev/null +++ b/app/pods/components/object/md-simple-array-table/component.js @@ -0,0 +1,67 @@ +import Ember from 'ember'; +import ArrayTable from '../md-array-table/component'; + +const { + computed, + observer +} = Ember; + +export default ArrayTable.extend({ + /** + * mdEditor component for input and edit of arrays of scalars. The + * component is rendered as an editable table. + * + * @class md-simple-array-table + * @module mdeditor + * @submodule components-object + * @extends md-array-table + * @constructor + */ + + layoutName: 'components/object/md-array-table', + + /** + * Convert the input 'primitive' array to an 'ember' array of objects + * + * @property arrayValues + * @type {Array} + * @category computed + * @requires value.[] + */ + arrayValues: computed('value.[]', { + get() { + let items = this.get('value'); + + if (items === undefined) { + items = []; + items[0] = ''; + } + + return items.reduce(function(acc, value) { + acc.pushObject({ + value: value + }); + return acc; + }, []); + }, + + set(key, value) { + this.set('value', value + .filterBy('value') + .mapBy('value')); + return value; + } + }), + + /** + * Set the value when arrayValues is updated + * + * @property valuesObserver + * @type {Observer} + * @category computed + * @requires arrayValues.@each.value + */ + valuesObserver: observer('arrayValues.@each.value', function() { + this.set('arrayValues', this.get('arrayValues')); + }) +}); diff --git a/app/pods/contact/show/edit/template.hbs b/app/pods/contact/show/edit/template.hbs index ae92742b9..7a85589d0 100644 --- a/app/pods/contact/show/edit/template.hbs +++ b/app/pods/contact/show/edit/template.hbs @@ -12,24 +12,28 @@ {{input/md-input value=model.json.name placeholder=(concat model.type " Name") label=(concat model.type " Name")}} - {{input/md-input value=model.json.positionName - placeholder="Position Name" label="Position Name"}} + {{#unless model.json.isOrganization}} + {{input/md-input value=model.json.positionName + placeholder="Position Name" label="Position Name"}} + {{/unless}} {{object/md-phone-array value=model.json.phone isCollapsed=false}} - {{#object/md-array-table + {{#object/md-simple-array-table columns="E-mail" title="E-mail Address" required=true value=model.json.electronicMailAddress as |email| }} - {{input/md-input value=email.item + {{input/md-input value=email.item.value placeholder="Enter valid e-mail address"}} - {{/object/md-array-table}} + {{/object/md-simple-array-table}} - {{!-- {{object/md-address address=model.json.address}} --}} + + + {{object/md-address model=model.json}} {{object/md-online-resource-array model=model.json}} diff --git a/tests/integration/pods/components/object/md-simple-array-table/component-test.js b/tests/integration/pods/components/object/md-simple-array-table/component-test.js new file mode 100644 index 000000000..6e5d5e104 --- /dev/null +++ b/tests/integration/pods/components/object/md-simple-array-table/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('object/md-simple-array-table', 'Integration | Component | object/md simple array table', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{object/md-simple-array-table}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#object/md-simple-array-table}} + template block text + {{/object/md-simple-array-table}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); From 6b9e48bd1b61c8862310711e167a905d5f5e6c0f Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Tue, 28 Mar 2017 19:25:42 -0800 Subject: [PATCH 007/383] Update codelist components Support valuePath, namePath, tooltipPath --- .../input/md-codelist-multi/component.js | 6 +- .../components/input/md-codelist/component.js | 73 +++++++++++++++---- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/app/pods/components/input/md-codelist-multi/component.js b/app/pods/components/input/md-codelist-multi/component.js index 91f7a4dfe..53aaab0d5 100644 --- a/app/pods/components/input/md-codelist-multi/component.js +++ b/app/pods/components/input/md-codelist-multi/component.js @@ -84,7 +84,7 @@ export default MdCodelist.extend({ if(value) { return codelist.filter((item) => { - return value.includes(item['codeName']); + return value.includes(item['codeId']); }); } return null; @@ -106,7 +106,7 @@ export default MdCodelist.extend({ if(value) { if(create) { value.forEach((val) => { - let found = codelist.findBy('codeName', val); + let found = codelist.findBy('codeId', val); if(found === undefined) { let newObject = this.createCode(val); codelist.pushObject(newObject); @@ -138,7 +138,7 @@ export default MdCodelist.extend({ sel = selected; } - this.set('value', sel.mapBy('codeName')); + this.set('value', sel.mapBy('codeId')); this.change(); } }); diff --git a/app/pods/components/input/md-codelist/component.js b/app/pods/components/input/md-codelist/component.js index a62f3403b..fe99c40bb 100644 --- a/app/pods/components/input/md-codelist/component.js +++ b/app/pods/components/input/md-codelist/component.js @@ -28,6 +28,38 @@ export default Select.extend({ * @required */ + /** + * Name of the attribute in the objectArray to be used for the + * select list's option value. + * + * @property valuePath + * @type String + * @default codeName + * @required + */ + valuePath: 'codeName', + /** + * Name of the attribute in the objectArray to be used for the + * select list's option name or display text. + * + * @property namePath + * @type String + * @default codename + * @required + */ + namePath: 'codeName', + + /** + * Name of the attribute in the objectArray to be used for the + * select list's tooltip. If null, no tooltip will be + * generated. + * + * @property tooltipPath + * @type String + * @default null + */ + tooltipPath: 'description', + /** * Initial value, returned value. * @@ -74,12 +106,12 @@ export default Select.extend({ * @type Ember.computed * @return PromiseObject */ - selectedItem: Ember.computed('value', function () { + selectedItem: Ember.computed('value', function() { let value = this.get('value'); return this.get('codelist') .find((item) => { - return item['codeName'] === value; + return item['codeId'] === value; }); }), @@ -91,7 +123,10 @@ export default Select.extend({ * @type Ember.computed * @return Array */ - mapped: Ember.computed('mdCodeName', function () { + mapped: Ember.computed('mdCodeName', function() { + let codeId = this.get('valuePath'); + let codeName = this.get('namePath'); + let tooltip = this.get('tooltipPath'); let codelist = []; let icons = this.get('icons'); let codelistName = this.get('mdCodeName'); @@ -100,11 +135,11 @@ export default Select.extend({ .codelist .sortBy('codeName'); - mdCodelist.forEach(function (item) { + mdCodelist.forEach(function(item) { let newObject = { - code: item['code'], - codeName: item['codeName'], - tooltip: item['description'], + codeId: item[codeId], + codeName: item[codeName], + tooltip: item[tooltip], icon: icons.get(item['codeName']) || icons.get( 'defaultList') }; @@ -122,15 +157,15 @@ export default Select.extend({ * @type Ember.computed * @return Array */ - codelist: Ember.computed('value', function () { + codelist: Ember.computed('value', function() { let codelist = this.get('mapped'); let value = this.get('value'); let create = this.get('create'); - if(value) { - if(create) { - let found = codelist.findBy('codeName', value); - if(found === undefined) { + if (value) { + if (create) { + let found = codelist.findBy('codeId', value); + if (found === undefined) { let newObject = this.createCode(value); codelist.pushObject(newObject); } @@ -149,7 +184,7 @@ export default Select.extend({ */ createCode(code) { return { - code: Math.floor(Math.random() * 100000) + 1, + codeId: code, codeName: code, description: 'Undefined' }; @@ -161,15 +196,21 @@ export default Select.extend({ * @method setValue * @param {Object} selected The object with the value(codeName) to set. */ - setValue(selected) { + /*setValue(selected) { + let valuePath = this.get('valuePath'); + let namePath = this.get('namePath'); + + if(selected) { + this.get('codelist') + } let val = selected ? selected.codeName : null; this.set('value', val); this.change(); - }, + },*/ actions: { // do the binding to value - setValue: function (selected) { + setValue: function(selected) { this.setValue(selected); }, //handle the create From db77cb893d9da067420911b11135f70dba7a5ac9 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Tue, 28 Mar 2017 19:26:07 -0800 Subject: [PATCH 008/383] Refactor md-input --- .../components/input/md-input/component.js | 2 ++ .../components/input/md-input/template.hbs | 31 ++++++------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/app/pods/components/input/md-input/component.js b/app/pods/components/input/md-input/component.js index 47ed6745e..02d53b5f5 100644 --- a/app/pods/components/input/md-input/component.js +++ b/app/pods/components/input/md-input/component.js @@ -13,6 +13,8 @@ export default Ember.Component.extend({ * @constructor */ + classNameBindings: ['label:form-group'], + /** * Value of the input. * Value sets the initial value and returns the edited result diff --git a/app/pods/components/input/md-input/template.hbs b/app/pods/components/input/md-input/template.hbs index d6dcc92da..48e2e7ec8 100644 --- a/app/pods/components/input/md-input/template.hbs +++ b/app/pods/components/input/md-input/template.hbs @@ -1,22 +1,9 @@ -{{#if label}} -
- - {{input - value=value - placeholder=placeholder - required=required - type=type - maxlength=maxlength - class=inputClass}} - {{yield}} -
-{{else}} - {{input - value=value - placeholder=placeholder - required=required - type=type - maxlength=maxlength - class=inputClass}} - {{yield}} -{{/if}} +{{#if label}}{{/if}} +{{input +value=value +placeholder=placeholder +required=required +type=type +maxlength=maxlength +class=inputClass}} +{{yield}} From 7aaec0a53d25afcb0a8c2247bb49b1cb7316eb12 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Tue, 28 Mar 2017 19:30:12 -0800 Subject: [PATCH 009/383] Update object components --- .../components/object/md-address/component.js | 4 +- .../components/object/md-address/template.hbs | 55 ++++--- .../object/md-array-table/component.js | 20 ++- .../object/md-array-table/template.hbs | 148 ++++++++++++------ .../object/md-object-table/component.js | 106 +++++++++---- .../object/md-object-table/template.hbs | 7 +- 6 files changed, 222 insertions(+), 118 deletions(-) diff --git a/app/pods/components/object/md-address/component.js b/app/pods/components/object/md-address/component.js index c184acad2..0791ab1f4 100644 --- a/app/pods/components/object/md-address/component.js +++ b/app/pods/components/object/md-address/component.js @@ -29,9 +29,9 @@ export default Ember.Component.extend({ * * @property attributes * @type String - * @default 'name, uri' + * @default '' */ - attributes: 'deliveryPoint.0,city', + attributes: 'city, adminstrativeArea, postalCode', /** * Name to place on the mdEditor panel header for entry and edit of diff --git a/app/pods/components/object/md-address/template.hbs b/app/pods/components/object/md-address/template.hbs index 5dffcdd2b..3f6b8852b 100644 --- a/app/pods/components/object/md-address/template.hbs +++ b/app/pods/components/object/md-address/template.hbs @@ -7,44 +7,53 @@ attributes=attributes as |address| }} - Editing: {{address.name}} + {{!-- Editing: {{address.name}} --}} {{!-- {{input/md-inputs model=address.deliveryPoint placeholder="Address line" label="Address Lines" buttonText="Add Line"}} --}} -{{!-- + {{#object/md-simple-array-table columns="Street" - title="Street" + title="Street Line" required=true + plain=true value=address.deliveryPoint as |line| }} {{input/md-input value=line.item.value placeholder="Enter street address"}} - {{/object/md-simple-array-table}} --}} - - {{input/md-input value=address.city - placeholder="City Name" label="City"}} - - {{input/md-input value=address.adminsitrativeArea - placeholder="State or Province" label="State/Province"}} - - {{input/md-input value=address.postalCode - placeholder="Zip or Postal Code" label="Postal Code"}} - - {{input/md-input value=address.country - placeholder="Country Name" label="Country"}} - -
- {{input/md-codelist - value=address.country - width="175px" - create=true tooltip=true icon=false mdCodeName="countries" - placeholder="Enter a country code"}} + {{/object/md-simple-array-table}} + +
+ {{input/md-input value=address.city class="col-md-6" + placeholder="City Name" label="City"}} + + {{input/md-input value=address.adminstrativeArea class="col-md-6" + placeholder="State or Province" label="State/Province"}} + + {{input/md-input value=address.postalCode class="col-md-6" + placeholder="Zip or Postal Code" label="Postal Code"}} + + {{!-- {{input/md-input value=address.country + placeholder="Country Name" label="Country"}} --}} + +
+ + {{input/md-codelist + value=address.country + namePath='description' + tooltipPath='codeName' + width="175px" + create=true tooltip=true icon=false mdCodeName="countries" + placeholder="Enter a country code"}} +
+ {{input/md-textarea value=address.description + placeholder="Address description" label="Description"}} + {{/object/md-object-table}} {{yield}} diff --git a/app/pods/components/object/md-array-table/component.js b/app/pods/components/object/md-array-table/component.js index 59f642f42..bc938b599 100644 --- a/app/pods/components/object/md-array-table/component.js +++ b/app/pods/components/object/md-array-table/component.js @@ -33,7 +33,7 @@ export default Component.extend({ * @default Ember.A() * @required */ - value: [], + value: A(), /** * The template class to use for new items. This should be a constructor. @@ -48,10 +48,10 @@ export default Component.extend({ * @property templateClass * @type {Any} * @constructor - * @default String + * @default null * @required */ - templateClass: String, + templateClass: null, /** * Comma-separated list of column headers to display in the table. If not @@ -62,13 +62,22 @@ export default Component.extend({ */ /** - * Inital collapse staet fo the panel. + * Inital collapse state fo the panel. * * @property isCollapsed * @type {Boolean} * @default undefined */ + /** + * Whether to render in a panel. + * + * @property plain + * @type {Boolean} + * @default false + */ + plain: false, + /** * Indicates whether at least one item is required is required in the value * array. @@ -194,8 +203,7 @@ export default Component.extend({ addItem: function(value) { const Template = this.get('templateClass'); - value.pushObject(typeOf(Template) === 'class' ? Template.create() : - new Template()); + value.pushObject(typeOf(Template) === 'class' ? Template.create() : null); this.valueChanged(); }, diff --git a/app/pods/components/object/md-array-table/template.hbs b/app/pods/components/object/md-array-table/template.hbs index 4e2702872..d0befe08c 100644 --- a/app/pods/components/object/md-array-table/template.hbs +++ b/app/pods/components/object/md-array-table/template.hbs @@ -1,58 +1,104 @@ -
+{{#if plain}} + + + {{#if columnArray}} + + + {{#each columnArray as |prop|}} + + {{/each}} + + + {{/if}} + + {{#each arrayValues as |item index|}} + + + {{yield (hash item=item index=index)}} + + + {{else}} + + + + {{/each}} + +
#{{uc-words prop}}
{{index}} +
+ +
+
+ +
+{{else}} +
- + - -
-
+
+{{/if}} diff --git a/app/pods/components/object/md-object-table/component.js b/app/pods/components/object/md-object-table/component.js index 8f76733ec..ef8b607fa 100644 --- a/app/pods/components/object/md-object-table/component.js +++ b/app/pods/components/object/md-object-table/component.js @@ -1,17 +1,22 @@ -/** - * @module mdeditor - * @submodule components-object - */ - import Ember from 'ember'; -export default Ember.Component.extend({ +const { + computed, + Component, + observer, + generateGuid, + isEmpty +} = Ember; + +export default Component.extend({ /** * mdEditor class for managing a table of similar mdJSON objects * for selection for edit or deletion. * The class is configurable for reuse with mdJSON object arrays. * + * @module mdeditor + * @submodule components-object * @class md-object-table * @constructor */ @@ -53,55 +58,90 @@ export default Ember.Component.extend({ */ buttonText: "Add", - panelId: Ember.computed(function () { - return Ember.generateGuid(null, 'panel'); + /** + * Inital collapse state fo the panel. + * + * @property isCollapsed + * @type {Boolean} + * @default undefined + */ + + /** + * Uses isCollapsed if defined, otherwise inspects array length. + * + * @property collapsed + * @type {Boolean} + * @readOnly + * @category computed + * @requires isCollapsed + */ + collapsed: computed('isCollapsed', function() { + let isCollapsed = this.get('isCollapsed'); + let value = this.get('items'); + + if (isCollapsed !== undefined) { + return isCollapsed; + } else if (value && value.length > 0) { + return false; + } else { + return true; + } + }), + + panelId: computed(function() { + return generateGuid(null, 'panel'); }), - citems: Ember.computed(function () { + citems: computed(function() { let i = this.get('items') - .map(function (itm) { + .map(function(itm) { return Ember.Object.create(itm); }); return i; }) .property('items.@each.val', 'editing'), - attrArray: Ember.computed(function () { - return this.get('attributes') - .split(','); - }) - .property('attributes'), + attrArray: computed('attributes', function() { + return this.get('attributes') + .split(','); + }), + + attrTitleArray: computed('attrArray', function() { + return this.get('attrArray').map(function(item) { + return item.trim().dasherize().replace(/-/g, ' '); + }); + }), editing: false, - editingChanged: Ember.observer('editing', function () { + editingChanged: observer('editing', function() { // deal with the change //Ember.run.schedule('afterRender', this, function () { - let panel = this.$('.panel-collapse'); - let table = this.$('table, .object-editor'); + let panel = this.$('.md-object-table > .panel-collapse'); + let table = panel.find('> .panel-body > table, > .panel-body > .object-editor'); let items = this.get('items'); let editing = this.get('editing'); - if(editing === 'adding') { + if (editing === 'adding') { items.pushObject(this.get('saveItem')); } - if(editing === false && items.length) { + if (editing === false && items.length) { let last = Object.keys(items.get('lastObject')); //TODO: this is fixed in 2.5.1 - //https://github.com/emberjs/ember.js/issues/13050 - last = last.filter(function (itm) { + //https://github.com/emberjs/js/issues/13050 + last = last.filter(function(itm) { return itm !== 'toString'; }); - if(Ember.isEmpty(last)) { + if (isEmpty(last)) { items.popObject(); } } - if(panel.hasClass('in')) { + if (panel.hasClass('in')) { table.toggleClass('fadeOut fadeIn'); } else { //add a one-time listener to wait until panel is open - panel.one('shown.bs.collapse', function () { + panel.one('shown.bs.collapse', function() { table.toggleClass('fadeOut fadeIn'); }); panel.collapse('show'); @@ -109,13 +149,13 @@ export default Ember.Component.extend({ //}); }), - pillColor: Ember.computed('citems.[]', function () { + pillColor: computed('citems.[]', function() { let count = this.get('citems') .length; - return(count > 0) ? 'label-info' : 'label-warning'; + return (count > 0) ? 'label-info' : 'label-warning'; }), - didInsertElement: function () { + didInsertElement: function() { /*let panel = this.get('panelId'); let panelBtn = panel + '-btn'; $('#' + panel).on('show.bs.collapse', function() { @@ -127,25 +167,25 @@ export default Ember.Component.extend({ }, actions: { - deleteItem: function (items, index) { + deleteItem: function(items, index) { //if (window.confirm("Do you really want to delete this " + this.get('header') + "?")) { items.removeAt(index); //} }, - addItem: function () { - //let itm = items.pushObject(Ember.Object.create({})); + addItem: function() { + //let itm = items.pushObject(Object.create({})); let itm = Ember.Object.create({}); this.set('saveItem', itm); this.set('editing', 'adding'); }, - editItem: function (items, index) { + editItem: function(items, index) { this.set('saveItem', items.objectAt(index)); this.set('editing', 'editing'); }, - cancelEdit: function () { + cancelEdit: function() { this.set('editing', false); } } diff --git a/app/pods/components/object/md-object-table/template.hbs b/app/pods/components/object/md-object-table/template.hbs index e47366483..26b08b446 100644 --- a/app/pods/components/object/md-object-table/template.hbs +++ b/app/pods/components/object/md-object-table/template.hbs @@ -2,7 +2,8 @@ -
+ +
- {{#layout/md-card title="E-mail" class="col-md-6 col-xxl-4"}} + {{#layout/md-card title="E-mail" class=""}} {{/layout/md-card}} +
+
- {{#layout/md-card title="Availability" class="col-md-6 col-xxl-4"}} + {{#layout/md-card title="Availability" class=""}}
    {{#each model.json.hoursOfService as |hours|}}
  • {{hours}}
  • @@ -101,9 +106,11 @@
{{/layout/md-card}}
+
- {{#layout/md-card title="Address" class="col-md-6" bodyIsRow=model.json.address.length}} +
+ {{#layout/md-card title="Address" bodyIsRow=model.json.address.length}} {{#each model.json.address as |address|}}
@@ -116,8 +123,9 @@ No addresses provided. {{/each}} {{/layout/md-card}} - - {{#layout/md-card title="Online Resource" class="col-md-6"}} +
+
+ {{#layout/md-card title="Online Resource"}}
@@ -148,6 +156,7 @@ {{/layout/md-card}} +
From 419b1a217a184785b8ed0221403c908a42e1df1e Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 17:35:18 -0800 Subject: [PATCH 083/383] Move ISO Topic categories to keywords Add iso_topicCategory codelist to keyword service. Closes #106 --- app/pods/record/show/edit/main/template.hbs | 3 +- app/services/keyword.js | 45 +++++++++++++++++---- app/services/profile.js | 1 - package.json | 2 +- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/app/pods/record/show/edit/main/template.hbs b/app/pods/record/show/edit/main/template.hbs index b0a67c743..f84074ca7 100644 --- a/app/pods/record/show/edit/main/template.hbs +++ b/app/pods/record/show/edit/main/template.hbs @@ -20,11 +20,12 @@ profilePath="record.main.status" }} - {{input/md-codelist-multi + {{!-- {{input/md-codelist-multi value=resource.topicCategory label="ISO Topic Category" create=false tooltip=true icon=false mdCodeName="topicCategory" placeholder="Select one or more topic categories" profilePath="record.main.topicCategory" + }} --}} }} {{/layout/md-card}} diff --git a/app/services/keyword.js b/app/services/keyword.js index 08ece6970..ff8988fd9 100644 --- a/app/services/keyword.js +++ b/app/services/keyword.js @@ -1,24 +1,25 @@ import Ember from 'ember'; import GCMD from 'npm:gcmd-keywords'; +import ISO from 'npm:mdcodes/resources/js/iso_topicCategory'; let service = Ember.Object.create({ thesaurus: Ember.A(), findById(id) { return this.get('thesaurus') - .find(function (t) { + .find(function(t) { return t.citation.identifier[0].identifier === id; }); } }); let type = { - 'Platforms': 'platform', - 'Instruments': 'instrument' - }; + 'Platforms': 'platform', + 'Instruments': 'instrument' +}; - Object.keys(GCMD) - .forEach(function (key) { - if(Array.isArray(GCMD[key])) { +Object.keys(GCMD) + .forEach(function(key) { + if (Array.isArray(GCMD[key])) { service.get('thesaurus') .pushObject({ citation: { @@ -42,4 +43,34 @@ let type = { } }); +let isoKeywords = ISO.codelist.map((topic) => { + return { + label: topic.codeName, + definition: topic.description, + uuid: topic.code + }; + +}); + +service.get('thesaurus') + .pushObject({ + citation: { + date: [{ + date: '2014-04', + dateType: 'revision' + }], + title: 'ISO 19115 Topic Category', + edition: 'ISO 19115-1:2014', + onlineResource: [{ + uri: 'https://doi.org/10.18123/D6RP4M' + }], + identifier: [{ + identifier: 'ISO 19115 Topic Category' + }] + }, + keywords: isoKeywords, + keywordType: 'isoTopicCategory', + label: 'ISO Topic Category' + }); + export default Ember.Service.extend(service); diff --git a/app/services/profile.js b/app/services/profile.js index 5eda26654..b7ad584b4 100644 --- a/app/services/profile.js +++ b/app/services/profile.js @@ -84,7 +84,6 @@ export default Ember.Service.extend({ main: { recordId: true, status: true, - topicCategory: true, resourceType: true, description: true, abstract: true, diff --git a/package.json b/package.json index c16bb112c..28de92007 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "geojson-coords": "0.0.0", "loader.js": "^4.0.10", "lodash.has": "^4.5.2", - "mdcodes": "^2.1.5", + "mdcodes": "^2.1.6", "moment-timezone": "^0.5.13", "object-hash": "^1.1.7", "shapefile": "^0.6.2", From c2d11d8e41d127d69d314550b013c0157dbc35d9 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 17:36:49 -0800 Subject: [PATCH 084/383] Add md-locale component --- .../components/object/md-locale/component.js | 56 +++++++++++++++++++ .../components/object/md-locale/template.hbs | 43 ++++++++++++++ .../object/md-locale/component-test.js | 25 +++++++++ 3 files changed, 124 insertions(+) create mode 100644 app/pods/components/object/md-locale/component.js create mode 100644 app/pods/components/object/md-locale/template.hbs create mode 100644 tests/integration/pods/components/object/md-locale/component-test.js diff --git a/app/pods/components/object/md-locale/component.js b/app/pods/components/object/md-locale/component.js new file mode 100644 index 000000000..180f6e746 --- /dev/null +++ b/app/pods/components/object/md-locale/component.js @@ -0,0 +1,56 @@ +import Ember from 'ember'; +import Template from 'mdeditor/mixins/object-template'; +import { + validator, + buildValidations +} from 'ember-cp-validations'; + +const { + Component, + get, + set, + Object: EmObject +} = Ember; + +const Validations = buildValidations({ + 'language': validator('presence', { + presence: true, + ignoreBlank: true + }), + 'characterSet': validator('presence', { + presence: true, + ignoreBlank: true + }) +}); + +export default Component.extend(Template, { + init() { + this._super(...arguments); + + let model = get(this, 'model'); + let modelPath = get(this, 'modelPath'); + let value = modelPath ? get(model, modelPath) : model; + + value = this.applyTemplate(value); + + if (modelPath) { + set(model, modelPath, value); + } + + set(this, 'value', value); + }, + +//value:{}, + /** + * This templateClass to apply to the supplied model or model.modelPath. + * + * @property templateClass + * @type Ember.Object + */ + templateClass: EmObject.extend(Validations, { + init() { + this._super(...arguments); + //this.set('uri', null); + } + }) +}); diff --git a/app/pods/components/object/md-locale/template.hbs b/app/pods/components/object/md-locale/template.hbs new file mode 100644 index 000000000..4a126fcbd --- /dev/null +++ b/app/pods/components/object/md-locale/template.hbs @@ -0,0 +1,43 @@ +
+
+ {{input/md-codelist + path="language" + model=value + create=true + tooltip=true + icon=false + disabled=disabled + mdCodeName="language" + label="Language" + showValidations=true + placeholder="Select or enter a language code." + }} +
+
+ {{input/md-codelist + path="characterSet" + model=value + create=false + tooltip=true + icon=false + disabled=disabled + mdCodeName="characterSet" + label="Character Set" + showValidations=true + placeholder="Select character set." + }} +
+
+ {{input/md-codelist + value=value.country + create=false + tooltip=true + icon=false + disabled=disabled + mdCodeName="countries" + label="Country" + placeholder="Select country code." + }} +
+
+{{yield}} diff --git a/tests/integration/pods/components/object/md-locale/component-test.js b/tests/integration/pods/components/object/md-locale/component-test.js new file mode 100644 index 000000000..d3975e2d7 --- /dev/null +++ b/tests/integration/pods/components/object/md-locale/component-test.js @@ -0,0 +1,25 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('object/md-locale', 'Integration | Component | object/md locale', { + integration: true +}); + +test('it renders', function(assert) { + + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.on('myAction', function(val) { ... }); + + this.render(hbs`{{object/md-locale}}`); + + assert.equal(this.$().text().trim(), ''); + + // Template block usage: + this.render(hbs` + {{#object/md-locale}} + template block text + {{/object/md-locale}} + `); + + assert.equal(this.$().text().trim(), 'template block text'); +}); From 770eff9dee5eebcb24868d5bc0389f750345df9b Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 17:37:46 -0800 Subject: [PATCH 085/383] Update components, object-template mixin --- app/mixins/object-template.js | 26 ++++++++++++++++--- .../components/input/md-select/component.js | 3 ++- .../object/md-array-table/component.js | 2 +- .../object/md-object-table/component.js | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/app/mixins/object-template.js b/app/mixins/object-template.js index 602f32bdc..17e9cd849 100644 --- a/app/mixins/object-template.js +++ b/app/mixins/object-template.js @@ -22,6 +22,26 @@ export default Mixin.create({ * @submodule mixins */ + /** + * Apply the 'template' to the object. + * + * @method applyTemplate + * @param {Object} object The object to apply the template to. + * @return {Ember.Object} + */ + applyTemplate(object) { + let value = object || {}; + let Template = this.get('templateClass'); + + if (Template) { + let owner = getOwner(this); + + return merge(Template.create(owner.ownerInjection()), value); + } + + return object; + }, + /** * Apply the object 'template' to each object in the array. * @@ -29,12 +49,12 @@ export default Mixin.create({ * @param {Array} propertyName The array of objects to apply the template to. * @return {Array} */ - applyTemplate(propertyName) { + applyTemplateArray(propertyName) { let property = this.get(propertyName); - if(isArray(property)) { + if (isArray(property)) { let Template = this.get('templateClass'); - if(Template) { + if (Template) { let owner = getOwner(this); property.forEach((item, idx, items) => { diff --git a/app/pods/components/input/md-select/component.js b/app/pods/components/input/md-select/component.js index 5c1728a5a..621e78932 100644 --- a/app/pods/components/input/md-select/component.js +++ b/app/pods/components/input/md-select/component.js @@ -10,6 +10,7 @@ const { Component, defineProperty, computed, + isNone, isBlank, assert } = Ember; @@ -21,7 +22,7 @@ export default Component.extend({ let model = this.get('model'); let path = this.get('path'); - if (isBlank(model) !== isBlank(path)) { + if (isNone(model) !== isNone(path)) { assert( `You must supply both model and path to ${this.toString()} or neither.` ); diff --git a/app/pods/components/object/md-array-table/component.js b/app/pods/components/object/md-array-table/component.js index b9510e4e6..4b10228c0 100644 --- a/app/pods/components/object/md-array-table/component.js +++ b/app/pods/components/object/md-array-table/component.js @@ -25,7 +25,7 @@ export default Component.extend(Template, { init() { this._super(...arguments); - this.applyTemplate('value'); + this.applyTemplateArray('value'); /*const Validation = this.get('validation'); diff --git a/app/pods/components/object/md-object-table/component.js b/app/pods/components/object/md-object-table/component.js index fc4c60d12..4effd5771 100644 --- a/app/pods/components/object/md-object-table/component.js +++ b/app/pods/components/object/md-object-table/component.js @@ -28,7 +28,7 @@ export default Component.extend(Template, { init() { this._super(...arguments); - this.applyTemplate('items'); + this.applyTemplateArray('items'); }, attributeBindings: ['data-spy'], From 4d750fd054d0457cf387d7e4ec660cf954b2ed85 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 17:38:05 -0800 Subject: [PATCH 086/383] Update record routes, profile --- app/pods/record/show/edit/main/template.hbs | 10 ++++++++++ app/pods/records/route.js | 8 ++------ app/services/profile.js | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/pods/record/show/edit/main/template.hbs b/app/pods/record/show/edit/main/template.hbs index f84074ca7..f6bdcbb12 100644 --- a/app/pods/record/show/edit/main/template.hbs +++ b/app/pods/record/show/edit/main/template.hbs @@ -26,7 +26,17 @@ placeholder="Select one or more topic categories" profilePath="record.main.topicCategory" }} --}} + + {{#layout/md-card + title="Default Locale" + shadow=false + data-spy=false + required=true + path="record.main.defaultResourceLocale" }} + {{object/md-locale model=resource modelPath="defaultResourceLocale"}} + {{/layout/md-card}} + {{/layout/md-card}}
diff --git a/app/pods/records/route.js b/app/pods/records/route.js index 6e47fbcaf..a36e4e3be 100644 --- a/app/pods/records/route.js +++ b/app/pods/records/route.js @@ -17,9 +17,7 @@ export default Ember.Route.extend({ actions: { deleteItem: function(item) { - let message = - "Do you really want to delete this record?"; - this._deleteItem(item, message); + this._deleteItem(item); }, editItem: function(item) { @@ -28,9 +26,7 @@ export default Ember.Route.extend({ }, // action methods - _deleteItem(item, message) { - if (window.confirm(message)) { + _deleteItem(item) { item.destroyRecord(); - } } }); diff --git a/app/services/profile.js b/app/services/profile.js index b7ad584b4..ac875536f 100644 --- a/app/services/profile.js +++ b/app/services/profile.js @@ -84,7 +84,9 @@ export default Ember.Service.extend({ main: { recordId: true, status: true, + defaultResourceLocale: true, resourceType: true, + pointOfContact: true, description: true, abstract: true, shortAbstract: true, @@ -121,6 +123,7 @@ export default Ember.Service.extend({ components: { record: { main: { + description: false, supplementalInfo: false, purpose: false, environmentDescription: false From db905429e9d318fb9dff991bdd618f7572b75ce2 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 20:06:21 -0800 Subject: [PATCH 087/383] Set locale default --- app/models/record.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/models/record.js b/app/models/record.js index 3b375c202..cb53b5cf2 100644 --- a/app/models/record.js +++ b/app/models/record.js @@ -72,9 +72,13 @@ export default Model.extend(Validations, Copyable, { }, 'pointOfContact': [], 'abstract': '', - 'shortAbstract':'', + 'shortAbstract': '', 'status': [], - 'language': ['eng; USA'] + 'defaultResourceLocale': { + 'characterSet': 'UTF-8', + 'country': 'USA', + 'language': 'eng' + }, } }, 'metadataRepository': [], @@ -91,11 +95,11 @@ export default Model.extend(Validations, Copyable, { }), title: computed('json.metadata.resourceInfo.citation.title', - function () { + function() { return this.get('json.metadata.resourceInfo.citation.title'); }), - icon: computed('json.metadata.resourceInfo.resourceType.[]', function () { + icon: computed('json.metadata.resourceInfo.resourceType.[]', function() { const type = this.get( 'json.metadata.resourceInfo.resourceType.0.type') || ''; const list = Ember.getOwner(this) @@ -117,9 +121,9 @@ export default Model.extend(Validations, Copyable, { * @category computed * @requires recordId */ - shortId: Ember.computed('recordId', function () { + shortId: Ember.computed('recordId', function() { const recordId = this.get('recordId'); - if(recordId) { + if (recordId) { let index = recordId.indexOf('-'); return recordId.substring(0, index > -1 ? index : 8); From 2d9ff082373329a5e92fe389e88f8458f7c9b99b Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 20:06:37 -0800 Subject: [PATCH 088/383] Fix delete all features --- app/pods/record/show/edit/spatial/extent/route.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/pods/record/show/edit/spatial/extent/route.js b/app/pods/record/show/edit/spatial/extent/route.js index fde6f21e2..e04650d05 100644 --- a/app/pods/record/show/edit/spatial/extent/route.js +++ b/app/pods/record/show/edit/spatial/extent/route.js @@ -55,6 +55,8 @@ export default Ember.Route.extend({ arr.replace(idx, 1, EmberObject.create(l)); }); + this.set('layers', layers); + return model; }, @@ -78,8 +80,7 @@ export default Ember.Route.extend({ .click(); }, deleteAllFeatures() { - let features = this.currentRouteModel() - .get('layers'); + let features = this.get('layers'); let group = this.controller .get('featureGroup'); From 6787892f2c2439d99e9a7b75fc44e8a2766df912 Mon Sep 17 00:00:00 2001 From: Josh Bradley Date: Wed, 17 May 2017 20:07:07 -0800 Subject: [PATCH 089/383] Update templates and profiles --- app/pods/dashboard/template.hbs | 173 +++----------------- app/pods/record/new/id/template.hbs | 5 +- app/pods/record/show/edit/main/template.hbs | 8 +- app/services/codelist.js | 4 + app/services/profile.js | 53 +++++- 5 files changed, 86 insertions(+), 157 deletions(-) diff --git a/app/pods/dashboard/template.hbs b/app/pods/dashboard/template.hbs index 820457970..6d9034ef3 100644 --- a/app/pods/dashboard/template.hbs +++ b/app/pods/dashboard/template.hbs @@ -1,151 +1,28 @@ -
-
- Generic placeholder thumbnail -

Label

- Something else -
-
- Generic placeholder thumbnail -

Label

- Something else -
-
- Generic placeholder thumbnail -

Label

- Something else -
-
- Generic placeholder thumbnail -

Label

- Something else -
+
+
+ {{#layout/md-card class="card-inverse card-primary text-center" + }} + {{model.0.length}} Records + {{/layout/md-card}}
+
+ {{#layout/md-card class="card-inverse card-success text-center" + }} + {{model.1.length}} Contacts + {{/layout/md-card}} +
+
+ {{#layout/md-card class="card-inverse card-info text-center" + }} + {{model.2.length}} Dictionaries + {{/layout/md-card}} +
+
-

Section title

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#HeaderHeaderHeaderHeader
1,001Loremipsumdolorsit
1,002ametconsecteturadipiscingelit
1,003IntegernecodioPraesent
1,003liberoSedcursusante
1,004dapibusdiamSednisi
1,005Nullaquissemat
1,006nibhelementumimperdietDuis
1,007sagittisipsumPraesentmauris
1,008Fuscenectellussed
1,009auguesemperportaMauris
1,010massaVestibulumlaciniaarcu
1,011egetnullaClassaptent
1,012tacitisociosquadlitora
1,013torquentperconubianostra
1,014perinceptoshimenaeosCurabitur
1,015sodalesligulainlibero
+
+
+

+ mdditor +

+
diff --git a/app/pods/record/new/id/template.hbs b/app/pods/record/new/id/template.hbs index 93cb95a9b..4c0e6d7fd 100644 --- a/app/pods/record/new/id/template.hbs +++ b/app/pods/record/new/id/template.hbs @@ -1,11 +1,12 @@