From 38ad445d6561f4f76b824281b54d45f1b4ab76df Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Thu, 1 Feb 2018 17:47:55 -0500 Subject: [PATCH 01/10] Remove interfering radio button package --- app/templates/activities.hbs | 28 ---------------------------- yarn.lock | 13 +++++-------- 2 files changed, 5 insertions(+), 36 deletions(-) delete mode 100644 app/templates/activities.hbs diff --git a/app/templates/activities.hbs b/app/templates/activities.hbs deleted file mode 100644 index ad24cd89..00000000 --- a/app/templates/activities.hbs +++ /dev/null @@ -1,28 +0,0 @@ -
-

My Activities

-
- - -
- In progress submissions to the {{collection.title}}. Any of the submissions may be continued by pressing the continue button. -
- -
-
-
Case No.
-
Form Type
-
-
- {{#each cases as |case|}} - - {{case-list-item case=case collection=collection}} - - {{else}} - -
- You have no active tasks -
- - {{/each}} -
- diff --git a/yarn.lock b/yarn.lock index aa61f79f..054dfc38 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,7 +22,6 @@ ember-i18n "5.0.1" ember-metrics "0.10.0" ember-moment "7.3.1" - ember-radio-buttons "4.0.3" ember-simple-auth "^1.3.0" ember-sinon "0.7.0" ember-sinon-qunit "1.6.0" @@ -3335,12 +3334,6 @@ ember-radio-button@^1.2.1: ember-cli-babel "^6.9.2" ember-cli-htmlbars "^1.1.1" -ember-radio-buttons@4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/ember-radio-buttons/-/ember-radio-buttons-4.0.3.tgz#1872f121987663960206eb10e70980a86498c2b1" - dependencies: - ember-cli-babel "^5.1.7" - ember-resolver@^2.0.3: version "2.1.1" resolved "https://registry.yarnpkg.com/ember-resolver/-/ember-resolver-2.1.1.tgz#5e4c1fffe9f5f48fc2194ad7592274ed0cd74f72" @@ -6840,7 +6833,7 @@ scss-tokenizer@^0.2.3: js-base64 "^2.1.8" source-map "^0.4.2" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.1.1, semver@^5.3.0, semver@^5.4.1: +"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.1.1, semver@^5.3.0: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" @@ -6848,6 +6841,10 @@ semver@^4.1.0, semver@^4.3.1: version "4.3.6" resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" +semver@^5.4.1: + version "5.5.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" + semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" From d50cdf3f97ae7ae8974801749f881c09b30b8025 Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Thu, 1 Feb 2018 17:48:23 -0500 Subject: [PATCH 02/10] Remove unused fields --- app/controllers/create.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/create.js b/app/controllers/create.js index 80866e54..a09d63b6 100644 --- a/app/controllers/create.js +++ b/app/controllers/create.js @@ -1,9 +1,6 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - title: '', - collectionWorkflows: [], - description: '', moderationStyle: false, collectionType: 'repository', submissionStyle: true, From 96c64c6d50008bcd229e06480ea215574047be31 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 1 Feb 2018 17:55:52 -0500 Subject: [PATCH 03/10] Update README.md --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index d243e72a..8d83c16d 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,35 @@ You will need the following things properly installed on your computer. $ yarn install $ bower install +After installing dependencies, you'll need to overwrite `node_modules/ember-crumbly/addon/templates/components/bread-crumb.hbs` with the following: + +``` +{{#if route.linkable}} + {{#if route.id}} + {{#link-to route.path route.id class=linkClass}} + {{route.title}} + {{/link-to}} + {{else}} + {{#link-to route.path class=linkClass}} + {{#if hasBlock}} + {{yield this route}} + {{else}} + {{route.title}} + {{/if}} + {{/link-to}} + {{/if}} +{{else}} + {{#if hasBlock}} + {{yield this route}} + {{else}} + {{route.title}} + {{/if}} +{{/if}} +``` + +This allows ember-crumbly to support record-specific / ID-specific route names ("People -> Angela" instead of "People -> Person"). A PR should be submitted to include this, but in the meantime this manual patch will have to do. + + ## Running From 6be36f2463cb516077a65601c59511c2c4e6d22d Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Thu, 1 Feb 2018 18:17:02 -0500 Subject: [PATCH 04/10] Refactor styling --- app/styles/app.scss | 19 ++++++++++++++----- app/templates/create.hbs | 18 ++---------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/app/styles/app.scss b/app/styles/app.scss index c2147a3f..e1d40d99 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -100,10 +100,19 @@ h2:hover > .headerlink { padding: 20px; } - -.case-number { - font-weight: 600; - color: #888; +.new-collection-form { + input { + width: 13px; + height: 13px; + padding: 0; + margin: 0; + position: relative; + top: -1px; + *overflow: hidden; + } + label { + padding: 5px 15px 0 15px; + } } h2 { @@ -866,7 +875,7 @@ span.sortable-bars:hover { } iframe { - height: calc(100vh - 60px); + height: calc(100vh - 60px); } .btn-space { diff --git a/app/templates/create.hbs b/app/templates/create.hbs index d4cd3216..b11b2374 100644 --- a/app/templates/create.hbs +++ b/app/templates/create.hbs @@ -1,20 +1,6 @@ - -

Create a collection

-
+ +

Add title

From f8698bc7ca5af38590316a39e8200f905902e105 Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 13:32:35 -0500 Subject: [PATCH 05/10] Add descriptions of mod and admin roles --- app/templates/collections/collection/edit.hbs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/templates/collections/collection/edit.hbs b/app/templates/collections/collection/edit.hbs index 3570ba81..0d9637cd 100644 --- a/app/templates/collections/collection/edit.hbs +++ b/app/templates/collections/collection/edit.hbs @@ -87,6 +87,7 @@
{{#if model.canAdmin}}

Moderators

+

Moderators are users who can approve or reject submissions to this collection.

@@ -112,6 +113,12 @@

Admins

+

+ If you can see this, you're an admin! Admins are users who, in addition to being able to approve or + reject submissions, can also edit the collection itself (update its layout, name, description, submission settings, etc.). + By default, the creator of a collection is its only admin. Any admin can add or remove moderators or other admins + besides the creator of the collection. +

From 6f457c8d8fb7b6e4b454d72fb70f85ff9c68f224 Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 13:39:43 -0500 Subject: [PATCH 06/10] Remove unneeded components All 'widget-*' components are holdovers from the workflows system and are thus obsoleted by recent changes. This commit removes those components, since they can no longer be used anywhere. --- app/components/widget-add-node/component.js | 133 ------- app/components/widget-add-node/template.hbs | 62 --- .../widget-add-website/component.js | 33 -- .../widget-add-website/template.hbs | 23 -- .../widget-appendix-submit/component.js | 127 ------ .../widget-appendix-submit/template.hbs | 7 - .../widget-approval-submit/component.js | 51 --- .../widget-approval-submit/template.hbs | 8 - app/components/widget-button/component.js | 33 -- app/components/widget-button/template.hbs | 4 - .../widget-choice-picker/component.js | 6 - .../widget-choice-picker/template.hbs | 8 - .../widget-datetime-field/component.js | 14 - .../widget-datetime-field/template.hbs | 22 -- .../widget-datetime-picker/component.js | 7 - .../widget-datetime-picker/template.hbs | 9 - .../widget-file-uploader/component.js | 29 -- .../widget-file-uploader/template.hbs | 16 - .../widget-item-display/component.js | 24 -- .../widget-item-display/template.hbs | 17 - .../widget-meeting-submit/component.js | 111 ------ .../widget-meeting-submit/template.hbs | 5 - .../widget-node-creator/component.js | 30 -- .../widget-node-creator/template.hbs | 0 app/components/widget-paragraph/component.js | 6 - app/components/widget-paragraph/template.hbs | 4 - .../widget-repository-submit/component.js | 143 ------- .../widget-repository-submit/template.hbs | 5 - .../widget-subject-picker/component.js | 243 ------------ .../widget-subject-picker/template.hbs | 70 ---- app/components/widget-text-area/component.js | 14 - app/components/widget-text-area/template.hbs | 25 -- app/components/widget-text-field/component.js | 25 -- app/components/widget-text-field/template.hbs | 28 -- .../widget-user-picker/component.js | 362 ------------------ .../widget-user-picker/template.hbs | 203 ---------- 36 files changed, 1907 deletions(-) delete mode 100644 app/components/widget-add-node/component.js delete mode 100644 app/components/widget-add-node/template.hbs delete mode 100644 app/components/widget-add-website/component.js delete mode 100644 app/components/widget-add-website/template.hbs delete mode 100644 app/components/widget-appendix-submit/component.js delete mode 100644 app/components/widget-appendix-submit/template.hbs delete mode 100644 app/components/widget-approval-submit/component.js delete mode 100644 app/components/widget-approval-submit/template.hbs delete mode 100644 app/components/widget-button/component.js delete mode 100644 app/components/widget-button/template.hbs delete mode 100644 app/components/widget-choice-picker/component.js delete mode 100644 app/components/widget-choice-picker/template.hbs delete mode 100644 app/components/widget-datetime-field/component.js delete mode 100644 app/components/widget-datetime-field/template.hbs delete mode 100644 app/components/widget-datetime-picker/component.js delete mode 100644 app/components/widget-datetime-picker/template.hbs delete mode 100644 app/components/widget-file-uploader/component.js delete mode 100644 app/components/widget-file-uploader/template.hbs delete mode 100644 app/components/widget-item-display/component.js delete mode 100644 app/components/widget-item-display/template.hbs delete mode 100644 app/components/widget-meeting-submit/component.js delete mode 100644 app/components/widget-meeting-submit/template.hbs delete mode 100644 app/components/widget-node-creator/component.js delete mode 100644 app/components/widget-node-creator/template.hbs delete mode 100644 app/components/widget-paragraph/component.js delete mode 100644 app/components/widget-paragraph/template.hbs delete mode 100644 app/components/widget-repository-submit/component.js delete mode 100644 app/components/widget-repository-submit/template.hbs delete mode 100644 app/components/widget-subject-picker/component.js delete mode 100644 app/components/widget-subject-picker/template.hbs delete mode 100644 app/components/widget-text-area/component.js delete mode 100644 app/components/widget-text-area/template.hbs delete mode 100644 app/components/widget-text-field/component.js delete mode 100644 app/components/widget-text-field/template.hbs delete mode 100644 app/components/widget-user-picker/component.js delete mode 100644 app/components/widget-user-picker/template.hbs diff --git a/app/components/widget-add-node/component.js b/app/components/widget-add-node/component.js deleted file mode 100644 index 830cad8a..00000000 --- a/app/components/widget-add-node/component.js +++ /dev/null @@ -1,133 +0,0 @@ -import Ember from 'ember'; - -const { - Component, - inject, - computed, -} = Ember; - -export default Component.extend({ - - store: inject.service(), - - showResults: false, - searchGuid: '', - searchFilter: '', - loadingItem: false, - showAddItemDetails: false, - findItemError: null, - results: null, - - newItemNode: Ember.Object.create(), - - displayItemType: computed('type', function() { - return this.get('type') === 'node' ? 'projects' : `${this.get('type')}s`; - }), - recordType: computed('type', function() { - const collectionType = this.get('type'); - return (collectionType === 'project' || collectionType === 'preprint') ? 'node' : collectionType; - }), - - didUpdateAttrs () { - this.clearView(); - this.clearFilters(); - }, - - actions: { - findNode () { - if (!this.get('searchGuid')) { - return; - } - this.clearView(); - this.set('loadingItem', true); - // We need to add type variable here because there is no - // model for project in ember-osf but 'node - const type = this.get('type') === 'project' ? 'node' : this.get('type'); - this.get('store').findRecord(type, this.get('searchGuid')).then((item) => { - if (this.get('type') === 'preprint') { - item.get('node').then((node) => { - item.set('title', node.get('title')); - this.buildNodeObject(node); - }); - } else { - this.buildNodeObject(item); - } - this.set('showAddItemDetails', true); - this.set('loadingItem', false); - }).catch((error) => { - this.clearView(); - this.clearFilters(); - this.set('findItemError', error.errors); - }); - }, - addItem(node) { - if (node) { - this.buildNodeObject(node); - } - const nodeObject = this.get('newItemNode'); - const item = this.get('store').createRecord('item', { - title: nodeObject.get('title'), - type: nodeObject.get('type'), - metadata: '', - status: 'pending', - url: nodeObject.get('link'), - sourceId: nodeObject.get('sourceId'), - collection: this.get('model'), - }); - item.save().then(() => { - this.get('transition')('collection.browse', this.get('model.id')); - }); - this.clearView(); - this.clearFilters(); - }, - searchNode () { - const filterText = this.get('searchFilter'); - if (!filterText) { - return; - } - this.clearView(); - this.set('loadingItem', true); - const filter = {}; - filter['filter[title]'] = filterText; - if (this.get('type') === 'preprint') { - filter['filter[preprint]'] = true; - } - this.get('store').query(this.get('recordType'), filter).then((results) => { - this.set('results', results); - this.set('loadingItem', false); - this.set('showResults', true); - }).catch((error) => { - this.clearView(); - this.clearFilters(); - this.set('findItemError', error.errors); - }); - }, - enterPressSearch() { - this.get('actions').searchNode.call(this); - }, - enterPressGuid() { - this.get('actions').findNode.call(this); - }, - }, - - clearFilters() { - this.set('searchGuid', ''); - this.set('searchFilter', ''); - }, - clearView() { - this.set('loadingItem', false); - this.set('showAddItemDetails', false); - this.set('findItemError', null); - this.set('results', null); - this.set('showResults', false); - }, - buildNodeObject (item) { - this.get('newItemNode').setProperties({ - title: item.get('title'), - description: item.get('description'), - type: this.get('type'), // set by the app based on selection of tab - sourceId: item.get('id'), - link: item.get('links.html'), - }); - }, -}); diff --git a/app/components/widget-add-node/template.hbs b/app/components/widget-add-node/template.hbs deleted file mode 100644 index 9145d093..00000000 --- a/app/components/widget-add-node/template.hbs +++ /dev/null @@ -1,62 +0,0 @@ -
-
-
-
{{input class="form-control" value=searchFilter placeholder="Search" enter="enterPressSearch"}}
-
{{input class="form-control" value=searchGuid placeholder="Enter guid" enter="enterPressGuid"}}
-
- - {{#if loadingItem}} -
-
-
-
-
-
-
-
-
- {{/if}} - - {{#if showResults}} - {{#if (gt results.length 0)}} -

Showing at most 10 items. Narrow search for better results.

- {{#each results as |result|}} -
{{result.title}}
- {{/each}} - {{else}} -

We couldn't find any {{displayItemType}} with this search. Please try another search.

- {{/if}} - {{/if}} - - {{#if findItemError}} -
-

- {{#each findItemError as |error|}} - {{error.detail}} - {{/each}} -

-

Please try again or try another {{displayItemType}} ID

-
- {{/if}} - - {{#if showAddItemDetails}} -
-

Title

-

{{newItemNode.title}}

- -

Description

-

{{newItemNode.description}}

- -

Type

-

{{newItemNode.type}}

- -
-
- -
-
-
- {{/if}} - -
-
diff --git a/app/components/widget-add-website/component.js b/app/components/widget-add-website/component.js deleted file mode 100644 index 884fdb6f..00000000 --- a/app/components/widget-add-website/component.js +++ /dev/null @@ -1,33 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - store: Ember.inject.service(), - urlTitle: '', - urlAddress: '', - urlDescription: '', - urlSaveErrors: null, - actions: { - addWebsite () { - const item = this.get('store').createRecord('item', { - title: this.get('urlTitle'), - type: 'website', - metadata: this.get('urlDescription'), - status: 'pending', - url: this.get('urlAddress'), - sourceId: this.get('urlAddress'), - collection: this.get('model'), - }); - item.save().then(() => { - this.get('transition')('collection.browse', this.get('model.id')); - }).catch((error) => { - this.set('urlSaveErrors', error.errors); - }); - this.clearInputs(); - }, - }, - clearInputs () { - this.set('urlTitle', ''); - this.set('urlAddress', ''); - this.set('urlDescription', ''); - }, -}); diff --git a/app/components/widget-add-website/template.hbs b/app/components/widget-add-website/template.hbs deleted file mode 100644 index 5b67d83e..00000000 --- a/app/components/widget-add-website/template.hbs +++ /dev/null @@ -1,23 +0,0 @@ -
-

Add a Website

-
-
- {{input class="form-control" value=urlTitle placeholder="Enter Title"}} -
-
- {{input class="form-control" value=urlAddress placeholder="Enter Address"}} -
-
-
-
- {{textarea class="form-control" value=urlDescription placeholder="Enter Notes"}} -
-
-
- -
- {{#each urlSaveErrors as |error|}} -
{{error.detail}}
- {{/each}} -
-
diff --git a/app/components/widget-appendix-submit/component.js b/app/components/widget-appendix-submit/component.js deleted file mode 100644 index 94a156e1..00000000 --- a/app/components/widget-appendix-submit/component.js +++ /dev/null @@ -1,127 +0,0 @@ -import Ember from 'ember'; -import ENV from '../../config/environment'; - -function getToken() { - let token; - const session = window.localStorage['ember_simple_auth-session']; - if (session) { - token = JSON.parse(session).authenticated; - if ('attributes' in token) { - return token.attributes.accessToken; - } - return token; - } -} - -export default Ember.Component.extend({ - - store: Ember.inject.service(), - - buttonString: 'Save', - disabled: false, - description: 'Submit', - - parameters: {}, - - typeObserver: Ember.observer('widget.parameters', 'widget.parameters.type.value', function() { - this.set('parameters.type', { - value: 'meeting' } - ); - }), - titleObserver: Ember.observer('widget.parameters', 'widget.parameters.title.value', function() { - this.set('parameters.title', this.get('widget.parameters.title')); - }), - statusObserver: Ember.observer('widget.parameters', 'widget.parameters.status.value', function() { - this.set('parameters.status', this.get('widget.parameters.status')); - }), - collectionObserver: Ember.observer('widget.parameters', 'widget.parameters.collection.value', function() { - this.set('parameters.collection', { - value: this.get('collection') - }); - }), - categoryObserver: Ember.observer('widget.parameters', 'widget.parameters.category.value', function() { - this.set('parameters.category', this.get('widget.parameters.category')); - }), - locationObserver: Ember.observer('widget.parameters', 'widget.parameters.location.value', function() { - this.set('parameters.location', this.get('widget.parameters.location')); - }), - startTimeObserver: Ember.observer('widget.parameters', 'widget.parameters.startTime.value', function() { - this.set('parameters.startTime', this.get('widget.parameters.startTime')); - }), - endTimeObserver: Ember.observer('widget.parameters', 'widget.parameters.endTime.value', function() { - this.set('parameters.endTime', this.get('widget.parameters.endTime')); - }), - descriptionObserver: Ember.observer('widget.parameters', 'widget.parameters.description.value', function() { - this.set('parameters.description', this.get('widget.parameters.description')); - }), - metadataObserver: Ember.observer('widget.parameters', 'widget.parameters.metadata.value', function() { - this.set('parameters.metadata', this.get('widget.parameters.metadata')); - }), - nodeObserver: Ember.observer('widget.parameters', 'widget.parameters.node.value', function() { - this.set('parameters.node', this.get('widget.parameters.node')); - }), - - init() { - this.set('parameters.type', { - value: 'meeting' } - ); - this.set('parameters.title', this.get('widget.parameters.title')); - this.set('parameters.status', this.get('widget.parameters.status')); - this.set('parameters.collection', { - value: this.get('collection') - }); - this.set('parameters.category', this.get('widget.parameters.category')); - this.set('parameters.location', this.get('widget.parameters.location')); - this.set('parameters.startTime', this.get('widget.parameters.startTime')); - this.set('parameters.endTime', this.get('widget.parameters.endTime')); - this.set('parameters.description', this.get('widget.parameters.description')); - this.set('parameters.metadata', this.get('widget.parameters.metadata')); - this.set('parameters.node', this.get('widget.parameters.node')); - return this._super(...arguments); - }, - - actions: { - async pressButton() { - const item = this.get('store').createRecord('item'); - item.set('type', 'meeting'); - item.set('title', this.get('parameters.eventTitle.value')); - // item.set('type', 'event'); - item.set('status', 'none'); - item.set('collection', this.get('collection')); - item.set('category', this.get('parameters.category.value')); - item.set('location', this.get('parameters.location.value')); - item.set('startTime', this.get('parameters.startTime.value')); - item.set('endTime', this.get('parameters.endTime.value')); - item.set('description', this.get('parameters.description.value')); - - // TODO: REPLACE THESE WITH REAL WIDGETS - item.set('metadata', '{}'); - item.set('sourceId', '3hgm5'); - item.set('url', 'http://example.com'); - - const node = this.get('widget.parameters.node.value'); - // const node = this.get('store').createRecord('node'); - // node.set('title', this.get('widget.parameters.title.value')); - // node.set('category', 'communication'); - await node.save(); - - const uri = `${ENV.OSF.waterbutlerUrl}v1/resources/${node.get('id')}/providers/osfstorage/?kind=file&name=${item.get('title')}&direct=true`; - - const xhr = new XMLHttpRequest(); - xhr.open('PUT', uri, true); - xhr.withCredentials = false; - xhr.setRequestHeader('Authorization', `Bearer ${getToken()}`); - - const deferred = Ember.RSVP.defer(); - xhr.onreadystatechange = () => { - if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) { - item.set('fileLink', JSON.parse(xhr.responseText).data.links.download); - item.save(); - } - }; - - xhr.send(this.get('widget.parameters.fileData.value')); - }, - }, - -}); diff --git a/app/components/widget-appendix-submit/template.hbs b/app/components/widget-appendix-submit/template.hbs deleted file mode 100644 index 5980ec3c..00000000 --- a/app/components/widget-appendix-submit/template.hbs +++ /dev/null @@ -1,7 +0,0 @@ - diff --git a/app/components/widget-approval-submit/component.js b/app/components/widget-approval-submit/component.js deleted file mode 100644 index cbd96767..00000000 --- a/app/components/widget-approval-submit/component.js +++ /dev/null @@ -1,51 +0,0 @@ -import Ember from 'ember'; -import ENV from '../../config/environment'; - -function getToken() { - let token; - const session = window.localStorage['ember_simple_auth-session']; - if (session) { - token = JSON.parse(session).authenticated; - if ('attributes' in token) { - return token.attributes.accessToken; - } - return token; - } -} - -export default Ember.Component.extend({ - - store: Ember.inject.service(), - - buttonString: 'Save', - disabled: false, - description: 'Submit', - - parameters: {}, - - init() { - this.set('parameters.type', { - value: 'meeting' } - ); - return this._super(...arguments); - }, - - actions: { - async pressButton() { - const item = await this.get('store').findRecord('item', this.get('parameters.item.value')); - item.set('location', this.get('parameters.eventRoom.value')); - item.set('startTime', this.get('parameters.startDate.value')); - item.set('endTime', this.get('parameters.endDate.value')); - if (this.get('parameters.approve.value')) item.set('status', 'approved'); - if (this.get('parameters.deny.value')) item.set('status', 'denied'); - await item.save(); - this.get('router') - .transitionTo( - 'items.item.index', - this.get('collection').id, - item.id - ); - }, - }, - -}); diff --git a/app/components/widget-approval-submit/template.hbs b/app/components/widget-approval-submit/template.hbs deleted file mode 100644 index be37aaba..00000000 --- a/app/components/widget-approval-submit/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/app/components/widget-button/component.js b/app/components/widget-button/component.js deleted file mode 100644 index 484614d7..00000000 --- a/app/components/widget-button/component.js +++ /dev/null @@ -1,33 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - buttonString: 'Save', - - widgetClasses: ['section-submit-button'], // eslint-disable-line ember/avoid-leaking-state-in-components - widgetClassString: Ember.computed('widgetClasses', function() { - const classes = this.get('widgetClasses'); - if (classes === undefined || - classes.constructor !== Array - ) { - return ''; - } - return classes.join(' '); - }), - - didReceiveAttrs() { - this.set('widgetClasses', this.attrs.widget.value.cssClasses); - }, - - actions: { - async pressButton() { - const parameters = this.attrs.widget.value.parameters; - this.attrs.saveParameter(parameters.parameter, { - value: await this.get('action')(this), - state: ['defined'], - }); - }, - }, - -}); diff --git a/app/components/widget-button/template.hbs b/app/components/widget-button/template.hbs deleted file mode 100644 index b0bbba06..00000000 --- a/app/components/widget-button/template.hbs +++ /dev/null @@ -1,4 +0,0 @@ - - \ No newline at end of file diff --git a/app/components/widget-choice-picker/component.js b/app/components/widget-choice-picker/component.js deleted file mode 100644 index 9b83e3b4..00000000 --- a/app/components/widget-choice-picker/component.js +++ /dev/null @@ -1,6 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ -}); - diff --git a/app/components/widget-choice-picker/template.hbs b/app/components/widget-choice-picker/template.hbs deleted file mode 100644 index cb2aabc9..00000000 --- a/app/components/widget-choice-picker/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ -{{widget.description}} - -{{#each parameters.choices.value as |choice|}} -
- {{radio-button id=choice.parameter value=choice.parameter name=choice.parameter checked=chosen}} - -
-{{/each}} diff --git a/app/components/widget-datetime-field/component.js b/app/components/widget-datetime-field/component.js deleted file mode 100644 index ccec7419..00000000 --- a/app/components/widget-datetime-field/component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - editing: true, - - description: 'Enter a start time for this presentation.', - - didReceiveAttrs() { - this.set('description', this.attrs.description); - }, - -}); diff --git a/app/components/widget-datetime-field/template.hbs b/app/components/widget-datetime-field/template.hbs deleted file mode 100644 index 293982bd..00000000 --- a/app/components/widget-datetime-field/template.hbs +++ /dev/null @@ -1,22 +0,0 @@ - - -{{#if (not editing)}} - - {{valueName}}: {{widget.parameters.date.value}} - -{{/if}} - -{{#if editing}} -
- - {{bs-datetimepicker date=parameters.date.value}} -
-{{/if}} -{{yield}} diff --git a/app/components/widget-datetime-picker/component.js b/app/components/widget-datetime-picker/component.js deleted file mode 100644 index a676572d..00000000 --- a/app/components/widget-datetime-picker/component.js +++ /dev/null @@ -1,7 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - - - pickerValue: null -}); diff --git a/app/components/widget-datetime-picker/template.hbs b/app/components/widget-datetime-picker/template.hbs deleted file mode 100644 index bccdb62c..00000000 --- a/app/components/widget-datetime-picker/template.hbs +++ /dev/null @@ -1,9 +0,0 @@ -
- hello -
- {{input class="form-control" value=editing}} - - - -
-
diff --git a/app/components/widget-file-uploader/component.js b/app/components/widget-file-uploader/component.js deleted file mode 100644 index 3cf2fbdd..00000000 --- a/app/components/widget-file-uploader/component.js +++ /dev/null @@ -1,29 +0,0 @@ -import Ember from 'ember'; -// import ENV from 'analytics-dashboard/config/environment'; - -export default Ember.Component.extend({ - - fileChosen: false, - - parameters: {}, - - actions: { - - uploadFile(ev) { - const reader = new FileReader(); - const fileHandle = ev.target.files[0]; - const filenameParts = ev.currentTarget.value.split('\\'); - const filename = filenameParts[filenameParts.length - 1]; - - reader.onloadend = (ev) => { - this.set('parameters.fileName.value', filename); - this.set('fileChosen', true); - const result = ev.target.result; - this.set('parameters.fileData.value', result); - }; - reader.readAsDataURL(fileHandle); - } - - }, - -}); diff --git a/app/components/widget-file-uploader/template.hbs b/app/components/widget-file-uploader/template.hbs deleted file mode 100644 index d9c83239..00000000 --- a/app/components/widget-file-uploader/template.hbs +++ /dev/null @@ -1,16 +0,0 @@ -
-
- {{#if fileChosen}} - {{widget.parameters.fileName.value}} selected for upload. - {{else}} - Select a preprint file to upload - {{/if}} -
- -
- -{{yield}} diff --git a/app/components/widget-item-display/component.js b/app/components/widget-item-display/component.js deleted file mode 100644 index fd9430b1..00000000 --- a/app/components/widget-item-display/component.js +++ /dev/null @@ -1,24 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - store: Ember.inject.service(), - - editing: true, - description: 'Enter a title for the preprint.', - - classNames: ['item-display'], - - item: undefined, - - didReceiveAttrs() { - this.set('description', this.attrs.description); - this.get('store') - .findRecord('item', this.get('parameters.value.value')) - .then((item) => { - this.set('item', item); - }); - }, - -}); diff --git a/app/components/widget-item-display/template.hbs b/app/components/widget-item-display/template.hbs deleted file mode 100644 index eaa71e93..00000000 --- a/app/components/widget-item-display/template.hbs +++ /dev/null @@ -1,17 +0,0 @@ -
-
Title
-
{{item.title}}
-
- -
-
Kind
-
{{item.kind}}
-
- -
-
Description
-
{{item.description}}
-
-

Materials

-{{file-renderer download=item.fileLink width="100%" allowfullscreen=true}} -{{yield}} diff --git a/app/components/widget-meeting-submit/component.js b/app/components/widget-meeting-submit/component.js deleted file mode 100644 index 565c52da..00000000 --- a/app/components/widget-meeting-submit/component.js +++ /dev/null @@ -1,111 +0,0 @@ -import Ember from 'ember'; -import ENV from '../../config/environment'; - -function getToken() { - let token; - const session = window.localStorage['ember_simple_auth-session']; - if (session) { - token = JSON.parse(session).authenticated; - if ('attributes' in token) { - return token.attributes.accessToken; - } - return token; - } -} - -export default Ember.Component.extend({ - - store: Ember.inject.service(), - - buttonString: 'Save', - disabled: false, - description: 'Submit', - - parameters: {}, - - init() { - this.set('parameters.type', { - value: 'meeting' - }); - return this._super(...arguments); - }, - - actions: { - async pressButton() { - this.attrs.toggleLoading(); - this.set('disabled', true); - let item = this.get('store').createRecord('item'); - if (Number(this.get('parameters.item.value')).isNaN() || - Number(this.get('parameters.item.value')) <= 0 - ) { - item = this.get('store').createRecord('item'); - } else { - item = await this.get('store').findRecord('item', this.get('parameters.item.value')); - } - item.set('kind', this.get('parameters.kind.value')); - item.set('title', this.get('parameters.title.value')); - item.set('status', this.get('parameters.submissionSuccessStatus')); - item.set('collection', this.get('collection')); - item.set('category', this.get('parameters.category.value')); - item.set('location', this.get('parameters.location.value')); - item.set('startTime', this.get('parameters.startTime.value')); - item.set('endTime', this.get('parameters.endTime.value')); - item.set('description', this.get('parameters.description.value')); - item.set('fileName', this.get('parameters.fileName.value')); - - // TODO: REPLACE THESE WITH REAL WIDGETS - item.set('metadata', '{}'); - - const node = this.get('parameters.node.value'); - if (node === undefined) { - this.set('disabled', false); - this.attrs.toggleLoading(); - this.toast.error('Some fields are missing!'); - return false; - } - await node.save(); - item.set('sourceId', node.get('id')); - const uri = `${ENV.OSF.waterbutlerUrl}v1/resources/${node.get('id')}/providers/osfstorage/?kind=file&name=${this.get('parameters.fileName.value')}&direct=true`; - - const xhr = new XMLHttpRequest(); - xhr.open('PUT', uri, true); - xhr.withCredentials = false; - xhr.setRequestHeader('Authorization', `Bearer ${getToken()}`); - - const deferred = Ember.RSVP.defer(); - xhr.onreadystatechange = () => { - if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) { - item.set('url', 'http://example.com'); - item.set('fileLink', JSON.parse(xhr.responseText).data.links.download); - item.save(); - } else if (xhr.readyState === 4 && xhr.status >= 409) { - this.attrs.toggleLoading(); - this.toast.error('Duplicate file!'); - this.set('disabled', false); - } else if (xhr.readyState === 4 && xhr.status >= 400) { - this.toast.error('Some fields are missing!'); - } - }; - // The base64 data needs to be converted to binary. - // We followed this stackoverflow answer: - // https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript - if (this.get('parameters.fileData.value') === null) { - this.set('disabled', false); - this.attrs.toggleLoading(); - this.toast.error('Some fields are missing!'); - return false; - } - const b64Data = this.get('parameters.fileData.value').split(',')[1]; - const contentType = this.get('parameters.fileData.value').split(',')[0]; - const binaryData = atob(b64Data); - const byteNumbers = new Array(binaryData.length); - for (let i = 0; i < binaryData.length; i++) { - byteNumbers[i] = binaryData.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - const blob = new Blob([byteArray], { type: contentType }); - xhr.send(blob); - }, - }, - -}); diff --git a/app/components/widget-meeting-submit/template.hbs b/app/components/widget-meeting-submit/template.hbs deleted file mode 100644 index 0c971427..00000000 --- a/app/components/widget-meeting-submit/template.hbs +++ /dev/null @@ -1,5 +0,0 @@ - -
-
diff --git a/app/components/widget-node-creator/component.js b/app/components/widget-node-creator/component.js deleted file mode 100644 index df4c3fa8..00000000 --- a/app/components/widget-node-creator/component.js +++ /dev/null @@ -1,30 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - chosen: null, - create: false, - node_created: false, - - store: Ember.inject.service(), - - createNodeObserver: Ember.observer('parameters.enable.value', function () { - Ember.run(() => { - this.get('parameters.node').disableAutosave = true; - if (this.get('parameters.enable.value') === true) { - this.set('parameters.node.value', this.get('node')); - } - }); - }), - - init() { - const node = this.get('store').createRecord('node'); - node.set('category', 'other'); - node.set('title', 'Created by collections submission form.'); - this.set('node', node); - return this._super(...arguments); - }, - -}); - diff --git a/app/components/widget-node-creator/template.hbs b/app/components/widget-node-creator/template.hbs deleted file mode 100644 index e69de29b..00000000 diff --git a/app/components/widget-paragraph/component.js b/app/components/widget-paragraph/component.js deleted file mode 100644 index 5d5fe3fe..00000000 --- a/app/components/widget-paragraph/component.js +++ /dev/null @@ -1,6 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - -}); diff --git a/app/components/widget-paragraph/template.hbs b/app/components/widget-paragraph/template.hbs deleted file mode 100644 index 136ce869..00000000 --- a/app/components/widget-paragraph/template.hbs +++ /dev/null @@ -1,4 +0,0 @@ -
-{{description}} -
-{{yield}} diff --git a/app/components/widget-repository-submit/component.js b/app/components/widget-repository-submit/component.js deleted file mode 100644 index 6e9dd61d..00000000 --- a/app/components/widget-repository-submit/component.js +++ /dev/null @@ -1,143 +0,0 @@ -import Ember from 'ember'; -import ENV from '../../config/environment'; - -function getToken() { - let token; - const session = window.localStorage['ember_simple_auth-session']; - if (session) { - token = JSON.parse(session).authenticated; - if ('attributes' in token) { - return token.attributes.accessToken; - } - return token; - } -} - -export default Ember.Component.extend({ - - store: Ember.inject.service(), - - buttonString: 'Save', - disabled: false, - description: 'Submit', - - parameters: {}, - - init() { - this.set('parameters.type', { value: 'meeting' }); - return this._super(...arguments); - }, - - actions: { - async pressButton() { - this.attrs.toggleLoading(); - this.set('disabled', true); - let item; - - if (isNaN(this.get('parameters.item.value')) || - Number(this.get('parameters.item.value')) <= 0 - ) { - item = this.get('store').createRecord('item'); - } else { - item = await this.get('store').findRecord('item', this.get('parameters.item.value')); - } - - item.set('kind', 'repository'); - item.set('title', this.get('parameters.title.value')); - item.set('status', this.get('parameters.submissionSuccessStatus.value')); - item.set('collection', this.get('collection')); - item.set('description', this.get('parameters.description.value')); - item.set('fileName', this.get('parameters.fileName.value')); - item.set('metadata', this.get('parameters.metadata.value')); - - const node = this.get('parameters.node.value'); - if (node === undefined) { - this.set('disabled', false); - this.attrs.toggleLoading(); - this.toast.error('Some fields are missing!'); - return false; - } - - node.set('public', true); - await node.save(); - item.set('sourceId', node.get('id')); - const uri = `${ENV.OSF.waterbutlerUrl}v1/resources/${node.get('id')}/providers/osfstorage/?kind=file&name=${this.get('parameters.fileName.value')}&direct=true`; - - const xhr = new XMLHttpRequest(); - xhr.open('PUT', uri, true); - xhr.withCredentials = false; - xhr.setRequestHeader('Authorization', `Bearer ${getToken()}`); - - const deferred = Ember.RSVP.defer(); - xhr.onreadystatechange = () => { - if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) { - item.set('url', 'http://example.com'); - item.set('fileLink', JSON.parse(xhr.responseText).data.links.download); - item.save().then((item) => { - this.set('parameters.item.value', item.id); - const workflowId = this.get('collection.collectionWorkflows').find(collectionWorkflow => collectionWorkflow.get('role') === 'approval').get('workflow.id'); - this.get('store').findRecord( - 'workflow', - workflowId, - { reload: true } - ).then((wf) => { - const caxe = this.get('store').createRecord('case'); - caxe.set('collection', this.get('collection')); - caxe.set('workflow', wf); - caxe.save().then((caxe) => { - this.get('store').queryRecord('parameter', { - name: 'item', - case: caxe.id - }).then((itemParameter) => { - if (!itemParameter) { - itemParameter = this.get('store').createRecord('parameter'); - itemParameter.disableAutosave = true; - itemParameter.set('workflow', wf); - itemParameter.set('name', 'item'); - itemParameter.get('cases').then(cases => cases.addObject(caxe)); - } - - itemParameter.set('value', item.id); - itemParameter.save().then(() => - this.get('router').transitionTo('items.item.index', this.get('collection').id, item.id)); - this.set('disabled', false); - this.attrs.toggleLoading(); - }); - }); - }); - }, (err) => { - console.log(err); - this.set('disabled', false); - this.attrs.toggleLoading(); - }); - } else if (xhr.readyState === 4 && xhr.status >= 409) { - this.attrs.toggleLoading(); - this.toast.error('Duplicate file!'); - this.set('disabled', false); - } else if (xhr.readyState === 4 && xhr.status >= 400) { - this.toast.error('Some fields are missing!'); - } - }; - // The base64 data needs to be converted to binary. - // We followed this stackoverflow answer: - // https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript - if (this.get('parameters.fileData.value') === null) { - this.set('disabled', false); - this.attrs.toggleLoading(); - this.toast.error('Some fields are missing!'); - return false; - } - const b64Data = this.get('parameters.fileData.value').split(',')[1]; - const contentType = this.get('parameters.fileData.value').split(',')[0]; - const binaryData = atob(b64Data); - const byteNumbers = new Array(binaryData.length); - for (let i = 0; i < binaryData.length; i++) { - byteNumbers[i] = binaryData.charCodeAt(i); - } - const byteArray = new Uint8Array(byteNumbers); - const blob = new Blob([byteArray], { type: contentType }); - xhr.send(blob); - }, - }, - -}); diff --git a/app/components/widget-repository-submit/template.hbs b/app/components/widget-repository-submit/template.hbs deleted file mode 100644 index 61576d4d..00000000 --- a/app/components/widget-repository-submit/template.hbs +++ /dev/null @@ -1,5 +0,0 @@ - -
-
diff --git a/app/components/widget-subject-picker/component.js b/app/components/widget-subject-picker/component.js deleted file mode 100644 index 48e09079..00000000 --- a/app/components/widget-subject-picker/component.js +++ /dev/null @@ -1,243 +0,0 @@ -import Ember from 'ember'; - -// Helper function to determine if discipline has changed (comparing list of lists) -function disciplineArraysEqual(a, b) { - if (a === b) return true; - if (a == null || b == null) return false; - if (a.length !== b.length) return false; - - for (let i = 0; i < a.length; ++i) { - if (a[i].length !== b[i].length) return false; - for (let j = 0; j < a[i].length; ++j) { - if (a[i][j] !== b[i][j]) return false; - } - } - return true; -} - -function subjectIdMap(subjectArray) { - // Maps array of arrays of disciplines into array of arrays of discipline ids. - return subjectArray.map(subjectBlock => subjectBlock.map(subject => subject.id)); -} - -function arrayEquals(arr1, arr2) { - return arr1.length === arr2.length - && arr1.reduce((acc, val, i) => acc && val === arr2[i], true); -} - -function arrayStartsWith(arr, prefix) { - return prefix.reduce((acc, val, i) => acc && val && arr[i] && val.id === arr[i].id, true); -} -/** - * @module ember-preprints - * @submodule components - */ - -/** - * Add discipline when creating a preprint. - * - * Sample usage: - * ```handlebars - * {{subject-picker - * editMode=editMode - * selected=subjectList - * disciplineModifiedToggle=disciplineModifiedToggle - * save=(action 'setSubjects') - *}} - * ``` - * @class subject-picker - */ -export default Ember.Component.extend({ - store: Ember.inject.service(), - theme: Ember.inject.service(), - - // Store the lists of subjects - _tier1: null, - _tier2: null, - _tier3: null, - // Filter the list of subjects if appropriate - tier1FilterText: '', - tier2FilterText: '', - tier3FilterText: '', - tierSorting: ['text:asc'], // eslint-disable-line ember/avoid-leaking-state-in-components - // Currently selected subjects - selection1: null, - selection2: null, - selection3: null, - disciplineModifiedToggle: false, - disciplineSaveState: false, - editMode: false, - - disciplineValid: Ember.computed.notEmpty('selected'), - - tier1Sorted: Ember.computed.sort('tier1Filtered', 'tierSorting'), - tier2Sorted: Ember.computed.sort('tier2Filtered', 'tierSorting'), - tier3Sorted: Ember.computed.sort('tier3Filtered', 'tierSorting'), - - tier1Filtered: Ember.computed('tier1FilterText', '_tier1.[]', function() { - const items = this.get('_tier1') || []; - const filterText = this.get('tier1FilterText').toLowerCase(); - if (filterText) { - return items.filter(item => item.get('text').toLowerCase().includes(filterText)); - } - return items; - }), - - tier2Filtered: Ember.computed('tier2FilterText', '_tier2.[]', function() { - const items = this.get('_tier2') || []; - const filterText = this.get('tier2FilterText').toLowerCase(); - if (filterText) { - return items.filter(item => item.get('text').toLowerCase().includes(filterText)); - } - return items; - }), - - tier3Filtered: Ember.computed('tier3FilterText', '_tier3.[]', function() { - const items = this.get('_tier3') || []; - const filterText = this.get('tier3FilterText').toLowerCase(); - if (filterText) { - return items.filter(item => item.get('text').toLowerCase().includes(filterText)); - } - return items; - }), - - // Pending subjects - subjectsList: Ember.computed('subjects.@each', function() { - return this.get('subjects') ? Ember.$.extend(true, [], this.get('subjects')) : Ember.A(); - }), - - // Flattened subject list - disciplineReduced: Ember.computed('subjects', function() { - return Ember.$.extend(true, [], this.get('subjects')).reduce((acc, val) => acc.concat(val), []).uniqBy('id'); - }), - - disciplineChanged: Ember.computed( - 'subjects.@each.subject', - 'selected.@each.subject', - 'disciplineModifiedToggle', - function() { - const changed = !(disciplineArraysEqual(subjectIdMap(this.get('subjects')), subjectIdMap(this.get('selected')))); - this.set('isSectionSaved', !changed); - return changed; - } - ), - - init() { - this._super(...arguments); - this.set('subjects', []); - this.set('selected', this.get('subjectsList')); - this.querySubjects(); - }, - - actions: { - deselect(subject) { - let index; - if (subject.length === 1) { - index = 0; - } else { - const parent = subject.slice(0, -1); - index = this.get('selected').findIndex(item => item !== subject && arrayStartsWith(item, parent)); - } - - let wipe = 4; // Tiers to clear - if (index === -1) { - if (this.get(`selection${subject.length}`) === subject[subject.length - 1]) wipe = subject.length + 1; - subject.removeAt(subject.length - 1); - } else { - this.get('selected').removeAt(this.get('selected').indexOf(subject)); - for (let i = 2; i < 4; i++) { - if (this.get(`selection${i}`) !== subject[i - 1]) continue; - wipe = i; - break; - } - } - - for (let i = wipe; i < 4; i++) { - this.set(`_tier${i}`, null); - this.set(`selection${i}`, null); - } - this.setSubjects(this.get('selected')); - }, - select(selected, tier) { - tier = parseInt(tier, 10); - if (this.get(`selection${tier}`) === selected) return; - - this.set(`selection${tier}`, selected); - - // Inserting the subject lol - let index = -1; - const selection = [...Array(tier).keys()].map(index => this.get(`selection${index + 1}`)); - - // An existing tag has this prefix, and this is the lowest level of the taxonomy, - // so no need to fetch child results - if (!(tier !== 3 && this.get('selected').findIndex(item => arrayStartsWith(item, selection)) !== -1)) { - for (let i = 0; i < selection.length; i++) { - const sub = selection.slice(0, i + 1); - // "deep" equals - index = this.get('selected').findIndex(item => arrayEquals(item, sub)); // jshint ignore:line - - if (index === -1) continue; - - this.get('selected')[index].pushObjects(selection.slice(i + 1)); - break; - } - - if (index === -1) { this.get('selected').pushObject(selection); } - } - - this.setSubjects(this.get('selected')); - - if (tier === 3) return; - - for (let i = tier + 1; i < 4; i++) { this.set(`_tier${i}`, null); } - - // TODO: Fires a network request every time clicking here, instead of only when needed? - this.querySubjects(selected.id, tier); - }, - discardSubjects() { - // Discards changes to subjects. (No requests sent, front-end only.) - this.set('selected', Ember.$.extend(true, [], this.get('subjects'))); - }, - saveSubjects() { - const subjectMap = Ember.$.extend(true, [], this.get('selected')); - this.get('action')(this).then(() => { - this.attrs.saveParameter(this.attrs.widget.value.parameters.subjects, { - value: subjectMap, - state: ['defined'], - }); - // Update subjects with selected subjects - this.set('subjects', Ember.$.extend(true, [], subjectMap)); - this.set('editMode', false); - // Prevent closing the section until it is valid - if (!this.get('disciplineChanged')) { - this.sendAction('closeSection', this.get('name')); - } - }); - }, - }, - querySubjects(parents = 'null', tier = 0) { - this.get('theme.provider') - .then(provider => provider - .query('taxonomies', { - filter: { - parents, - }, - page: { - size: 100, - }, - }), - ) - .then(results => this - .set(`_tier${tier + 1}`, results.toArray()), - ); - }, - - setSubjects(subjects) { - // Sets selected with pending subjects. Does not save. - const disciplineModifiedToggle = this.get('disciplineModifiedToggle'); - // Need to observe if discipline in nested array has changed. - // Toggling this will force 'disciplineChanged' to be recalculated - this.set('disciplineModifiedToggle', !disciplineModifiedToggle); - this.set('selected', subjects); - }, -}); diff --git a/app/components/widget-subject-picker/template.hbs b/app/components/widget-subject-picker/template.hbs deleted file mode 100644 index 9bb89d61..00000000 --- a/app/components/widget-subject-picker/template.hbs +++ /dev/null @@ -1,70 +0,0 @@ -{{#if (not isOpen)}} - {{#if disciplineReduced}} -
-
- {{#each disciplineReduced as |subject|}} - {{subject.text}} - {{/each}} -
-
- {{/if}} -{{/if}} - -{{#preprint-form-body}} - {{#if isOpen}} -
- {{#each selected as |subject|}} - - {{#each subject as |segment|}} - {{segment.text}} - {{/each}} - {{fa-icon 'times' click=(action 'deselect' subject)}} - - {{/each}} -
- -
- -
-
    - {{input value=tier1FilterText class="form-control" placeholder="Search"}} - {{#each tier1Sorted as |subject|}} -
  • - {{subject.text}} -
  • - {{/each}} -
-
- -
-
    - {{input value=tier2FilterText class="form-control" placeholder="Search"}} - {{#each tier2Sorted as |subject|}} -
  • - {{subject.text}} -
  • - {{/each}} -
-
- -
-
    - {{input value=tier3FilterText class="form-control" placeholder="Search"}} - {{#each tier3Sorted as |subject|}} -
  • - {{subject.text}} -
  • - {{/each}} -
-
-
-
-
-
- - -
-
-
- {{/if}} -{{/preprint-form-body}} diff --git a/app/components/widget-text-area/component.js b/app/components/widget-text-area/component.js deleted file mode 100644 index 5997605a..00000000 --- a/app/components/widget-text-area/component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - editing: true, - - description: 'Enter a title for the preprint.', - - didReceiveAttrs() { - this.set('description', this.attrs.description); - }, - -}); diff --git a/app/components/widget-text-area/template.hbs b/app/components/widget-text-area/template.hbs deleted file mode 100644 index ae18e58d..00000000 --- a/app/components/widget-text-area/template.hbs +++ /dev/null @@ -1,25 +0,0 @@ - - -{{#if (not editing)}} - - {{valueName}}: {{parameters.value.value}} - -{{/if}} - -{{#if editing}} -
- - {{textarea value=parameters.value.value class='form-control'}} -
-{{/if}} -{{yield}} diff --git a/app/components/widget-text-field/component.js b/app/components/widget-text-field/component.js deleted file mode 100644 index 2adb396a..00000000 --- a/app/components/widget-text-field/component.js +++ /dev/null @@ -1,25 +0,0 @@ -import Ember from 'ember'; - - -export default Ember.Component.extend({ - - editing: true, - - description: 'Enter a title for the preprint.', - metadata: false, - - didReceiveAttrs() { - this.set('description', this.attrs.description); - if(this.get('parameters.value.name') === 'metadata') { - this.set('metadata' , true) - }else { - this.set('metadata' , false) - } - }, - actions : { - updateCacheSettings (jsonSettings) { - this.set('parameters.value.value', jsonSettings); - }, - } - -}); diff --git a/app/components/widget-text-field/template.hbs b/app/components/widget-text-field/template.hbs deleted file mode 100644 index 8ab6295c..00000000 --- a/app/components/widget-text-field/template.hbs +++ /dev/null @@ -1,28 +0,0 @@ - - -{{#if (not editing)}} - - {{valueName}}: {{widget.parameter.value.value}} - -{{/if}} - -{{#if editing}} -
- - {{#if metadata}} - {{json-editor json=parameters.value.value onChange=(action "updateCacheSettings") }} - {{else}} - {{input value=parameters.value.value class='form-control'}} - {{/if}} - - -
-{{/if}} -{{yield}} diff --git a/app/components/widget-user-picker/component.js b/app/components/widget-user-picker/component.js deleted file mode 100644 index 673bdab4..00000000 --- a/app/components/widget-user-picker/component.js +++ /dev/null @@ -1,362 +0,0 @@ -import Ember from 'ember'; -import { permissionSelector } from 'ember-osf/const/permissions'; -import NodeActionsMixin from 'ember-osf/mixins/node-actions'; -import ENV from '../../config/environment'; - -/** - * @module ember-preprints - * @submodule components - */ - -/** - * Displays current preprint authors and their permissions/bibliographic information. - * Allows user to search for authors, add authors, edit authors permissions/bibliographic - * information, and remove authors. Actions that are not allowed are disabled (for - * example, you cannot remove the sole bibliographic author). - * @class preprint-form-authors - */ -export default Ember.Component.extend(NodeActionsMixin, { - i18n: Ember.inject.service(), - - // Variables that used to pass in from Controller - store: Ember.inject.service(), - toast: Ember.inject.service('toast'), - currentUser: Ember.inject.service('currentUser'), - editMode: 'Submit', // defaults, need update - parentNode: null, // defaults, need update - isAdmin: true, // defaults, need update - canEdit: true, // defaults, need update - node: null, - authorModification: false, - currentPage: 1, - // Permissions labels for dropdown - permissionOptions: permissionSelector, - parentContributorsAdded: false, - addState: 'emptyView', // There are 3 view states on left side of Authors panel. - // Default state just shows search bar. - query: null, - // In Add mode, contributors are emailed on creation of preprint. In Edit mode, - // contributors are emailed as soon as they are added to preprint. - sendEmail: false, - - parentContributors: Ember.A(), - searchResults: Ember.A(), // defaults, need update - - contributors: Ember.computed('node', function () { - const contribs = this.get('node.contributors'); - this.set('widget.parameter', { - contribs, - state: ['defined'] - }); - return contribs; - }), - // Returns list of user ids associated with current node - currentContributorIds: Ember.computed('contributors', function () { - const contribIds = []; - this.get('contributors').forEach(contrib => contribIds.push(contrib.get('userId'))); - return contribIds; - }), - // In Add mode, contributors are emailed on creation of preprint. In Edit mode, - // contributors are emailed as soon as they are added to preprint. - sendEmail: false, - editing: true, - numParentContributors: Ember.computed('parentNode', function() { - if (this.get('parentNode')) { - return this.get('parentNode').get('contributors').get('length'); - } else { - return 0; - } - }), - // Total contributor search results - totalSearchResults: Ember.computed('searchResults.[]', function () { - const searchResults = this.get('searchResults'); - if (searchResults && searchResults.links) { - return searchResults.meta.pagination.total; - } - }), - // Total pages of contributor search results - pages: Ember.computed('searchResults.[]', function () { - const searchResults = this.get('searchResults'); - if (searchResults && searchResults.links) { - return searchResults.meta.total; - } - }), - valid: Ember.observer('contributors.length', function () { - const hasContributors = this.get('contributors.length'); - this.set('isSectionSaved', hasContributors); - return hasContributors; - }), - elementsLoaded: Ember.observer('isOpen', function () { - if (this.get('isOpen')) { - Ember.run.once(this.get('applyPopovers').bind(this)); - } - }), - init() { - this._super(...arguments); - this.set('node', this.get('store').createRecord('node')); - }, - - actions: { - // Adds contributor then redraws view - addition of contributor - // may change which update/remove contributor requests are permitted - addContributorLocal(user) { - const node = this.get('node'); - if (node) { - const contributor = this.get('store').createRecord('contributor'); - contributor.set('users', user); - - node.get('contributors').pushObject(contributor); - window.nod = node; - - - // this.get('actions.addContributor').call(this, user.id, 'write', true, false, undefined, - // undefined, true) - // .then((res) => { - // this.toggleAuthorModification(); - // this.get('contributors').pushObject(res); - // this.get('toast').success(this.get('i18n').t('submit.preprint_author_added')); - // this.highlightSuccessOrFailure(res.id, this, 'success'); - // }, () => { - // this.get('toast').error(this.get('i18n').t('submit.error_adding_author')); - // this.highlightSuccessOrFailure(user.id, this, 'error'); - // user.rollbackAttributes(); - // }); - } else { - this.get('toast').error('No node selected'); - } - }, - // Adds all contributors from parent project to current - // component as long as they are not current contributors - addContributorsFromParentProject() { - this.set('parentContributorsAdded', true); - const contributorsToAdd = Ember.A(); - this.get('parentContributors').toArray().forEach((contributor) => { - if (this.get('currentContributorIds').indexOf(contributor.get('userId')) === -1) { - contributorsToAdd.push({ - permission: contributor.get('permission'), - bibliographic: contributor.get('bibliographic'), - userId: contributor.get('userId'), - }); - } - }); - this.get('actions.addContributors').call(this, contributorsToAdd, this.get('sendEmail')) - .then((contributors) => { - contributors.forEach((contrib) => { - this.get('contributors').pushObject(contrib); - }); - this.toggleAuthorModification(); - }) - .catch(() => { - this.get('toast').error('Some contributors may not have been added. ' + - 'Try adding manually.'); - }); - }, - // Adds unregistered contributor, then clears form and switches back to search view. - // Should wait to transition until request has completed. - addUnregisteredContributor(fullName, email) { - if (fullName && email) { - const res = this.get('actions.addContributor').call(this, null, 'write', true, - this.get('sendEmail'), fullName, email, true); - res.then((contributor) => { - this.get('contributors').pushObject(contributor); - this.toggleAuthorModification(); - this.set('addState', 'searchView'); - this.set('fullName', ''); - this.set('email', ''); - this.get('toast').success(this.get('i18n') - .t('submit.preprint_unregistered_author_added')); - this.highlightSuccessOrFailure(contributor.id, this, 'success'); - }, (error) => { - if (error.errors[0] && error.errors[0].detail && - error.errors[0].detail.indexOf('is already a contributor') > -1) { - this.get('toast').error(error.errors[0].detail); - } else { - this.get('toast').error(this.get('i18n') - .t('submit.error_adding_unregistered_author')); - } - this.highlightSuccessOrFailure('add-unregistered-contributor-form', - this, 'error'); - }); - } - }, - // Requests a particular page of user results - findContributors(page) { - const query = this.get('query'); - if (query) { - this.findContributors(query, page) - .then(() => this.set('addState', 'searchView'), () => { - this.get('toast').error('Could not perform search query.'); - this.highlightSuccessOrFailure('author-search-box', this, 'error'); - }); - } - }, - // Removes contributor then redraws contributor list view - - // removal of contributor may change which additional update/remove requests are permitted. - removeContributorLocal(contrib) { - this.get('actions.removeContributor').call(this, contrib).then(() => { - this.toggleAuthorModification(); - this.removedSelfAsAdmin(contrib, contrib.get('permission')); - this.get('contributors').removeObject(contrib); - this.get('toast').success(this.get('i18n').t('submit.preprint_author_removed')); - }, () => { - this.get('toast').error(this.get('i18n').t('submit.error_adding_author')); - this.highlightSuccessOrFailure(contrib.id, this, 'error'); - contrib.rollbackAttributes(); - }); - }, - // Updates contributor then redraws contributor list view - updating contributor - // permissions may change which additional update/remove requests are permitted. - updatePermissions(contributor, permission) { - this.get('actions.updateContributor').call(this, contributor, permission, '') - .then(() => { - this.toggleAuthorModification(); - this.highlightSuccessOrFailure(contributor.id, this, 'success'); - this.removedSelfAsAdmin(contributor, permission); - }, () => { - this.get('toast').error('Could not modify author permissions'); - this.highlightSuccessOrFailure(contributor.id, this, 'error'); - contributor.rollbackAttributes(); - }); - }, - // Updates contributor then redraws contributor list view - updating contributor - // bibliographic info may change which additional update/remove requests are permitted. - updateBibliographic(contributor, isBibliographic) { - this.get('actions.updateContributor').call(this, contributor, '', - isBibliographic).then(() => { - this.toggleAuthorModification(); - this.highlightSuccessOrFailure(contributor.id, this, 'success'); - }, () => { - this.get('toast').error('Could not modify citation'); - this.highlightSuccessOrFailure(contributor.id, this, 'error'); - contributor.rollbackAttributes(); - }); - }, - // There are 3 view states on left side of Authors panel. - // This switches to add unregistered contrib view. - unregisteredView() { - this.set('addState', 'unregisteredView'); - }, - // There are 3 view states on left side of Authors panel. - // This switches to searching contributor results view. - searchView() { - this.set('addState', 'searchView'); - this.set('fullName', ''); - this.set('email', ''); - }, - // There are 3 view states on left side of Authors panel. - // This switches to empty view and clears search results. - resetfindContributorsView() { - this.set('addState', 'searchView'); - }, - // Reorders contributors in UI then sends server request to reorder contributors. - // If request fails, reverts contributor list in UI back to original. - reorderItems(itemModels, draggedContrib) { - const originalOrder = this.get('contributors'); - this.set('contributors', itemModels); - const newIndex = itemModels.indexOf(draggedContrib); - this.get('actions.reorderContributors').call(this, draggedContrib, newIndex, - itemModels).then(() => { - this.highlightSuccessOrFailure(draggedContrib.id, this, 'success'); - }, () => { - this.highlightSuccessOrFailure(draggedContrib.id, this, 'error'); - this.set('contributors', originalOrder); - this.get('toast').error('Could not reorder contributors'); - draggedContrib.rollbackAttributes(); - }); - }, - // Action used by the pagination-pager component to the handle user-click event. - pageChanged(current) { - const query = this.get('query'); - if (query) { - this.findContributors(query, current).then(() => { - this.set('addState', 'searchView'); - this.set('currentPage', current); - }) - .catch(() => { - this.get('toast').error('Could not perform search query.'); - this.highlightSuccessOrFailure('author-search-box', this, 'error'); - }); - } - }, - }, - /** - * findContributors method. Queries APIv2 users endpoint on any of a set of name fields. - * Fetches specified page of results. - * @method findContributors - * @param {String} query ID of user that will be a contributor on the node - * @param {Integer} page Page number of results requested - * @return {User[]} Returns specified page of user records matching query - */ - findContributors(query, page) { - return this.get('store').query('osf-user', { - filter: { - 'full_name,given_name,middle_names,family_name': query, - }, - page, - }).then((contributors) => { - this.set('searchResults', contributors); - return contributors; - }).catch(() => { - this.get('toast').error(this.get('i18n').t('submit.search_contributors_error')); - this.highlightSuccessOrFailure('author-search-box', this, 'error'); - }); - }, - /* - * highlightSuccessOrFailure method. Element with specified ID flashes green or red - * depending on response success. - * - * @method highlightSuccessOrFailure - * @param {string} elementId Element ID to change color - * @param {Object} context "this" scope - * @param {string} status "success" or "error" - */ - highlightSuccessOrFailure(elementId, context, status) { - const highlightClass = `${status === 'success' ? 'success' : 'error'}Highlight`; - context.$(`#${elementId}`).addClass(highlightClass); - Ember.run.later(() => context.$(`#${elementId}`).removeClass(highlightClass), 2000); - }, - applyPopovers() { - this.$('#permissions-popover').popover({ - container: 'body', - content: '
' + - '
Read
' + - '
  • View preprint
' + - '
Read + Write
' + - '
  • Read privileges
  • ' + - '
  • Add and configure preprint
  • ' + - '
  • Add and edit content
' + - '
Administrator
    ' + - '
  • Read and write privileges
  • ' + - '
  • Manage authors
  • ' + - '
  • Public-private settings
' + - '
', - }); - this.$('#bibliographic-popover').popover({ - container: 'body', - content: 'Only checked authors will be included in preprint citations. ' + - 'Authors not in the citation can read and modify the preprint as normal.', - }); - this.$('#author-popover').popover({ - container: 'body', - content: 'Preprints must have at least one registered administrator ' + - 'and one author showing ' + - 'in the citation at all times. ' + - 'A registered administrator is a user who has both confirmed their account and has ' + - 'administrator privileges.', - }); - }, - - /* If user removes their own admin permissions, many things on the page must become - disabled. Changing the isAdmin flag to false will remove many of the options - on the page. */ - removedSelfAsAdmin(contributor, permission) { - if (this.get('currentUser').id === contributor.get('userId') && permission !== 'ADMIN') { - this.set('isAdmin', false); - } - }, - /* Toggling this property, authorModification, updates several items on the page - - disabling elements, enabling others, depending on what requests are permitted */ - toggleAuthorModification() { - this.toggleProperty('authorModification'); - }, -}); diff --git a/app/components/widget-user-picker/template.hbs b/app/components/widget-user-picker/template.hbs deleted file mode 100644 index c3161a95..00000000 --- a/app/components/widget-user-picker/template.hbs +++ /dev/null @@ -1,203 +0,0 @@ - {{#if editing}} -
-
-
- - - {{#if (not-eq addState 'emptyView')}} - {{#if (eq addState 'searchView')}} - -

{{t "components.preprint-form-authors.results"}}

- {{#if searchResults}} -
- {{#each searchResults as |result|}} - - - - - {{/each}} -
- - {{result.fullName}} - {{#if (eq currentUser result)}} - {{t "components.preprint-form-authors.yourself"}} - {{/if}} - - {{#if (user-is-contributor result contributors authorModification)}} - - - - {{else}} - - {{/if}} -
- {{else}} - {{t "global.no_results_found"}} - {{/if}} - {{#if (gt pages 1)}} -
- {{pagination-pager count=pages current=currentPage change=(action 'pageChanged')}} -
- {{/if}} - {{/if}} - {{#if (eq addState 'unregisteredView')}} -

{{t "components.preprint-form-authors.add_email"}}

-
- {{unregistered-contributor-form editMode=editMode resetfindContributorsView=(action 'resetfindContributorsView') addUnregisteredContributor=(action 'addUnregisteredContributor')}} -
- {{/if}} - {{/if}} - -
-
-

{{t "global.authors"}}

- - - - - {{#if (and (gt numParentContributors 1) (not parentContributorsAdded))}} - - {{/if}} -
-

{{t "components.preprint-form-authors.authors.order_instructions"}}

-
- - - - - - - - - {{#sortable-group tagName="tbody" onChange="reorderItems" as |group|}} - {{#each contributors as |contrib|}} - {{#sortable-item tagName="tr" model=contrib class="contributor-row" group=group spacing=1 handle=".handle" id=contrib.id}} - - - - - - {{/sortable-item}} - {{/each}} - {{/sortable-group}} -
{{t "components.preprint-form-authors.authors.name"}} - {{t "components.preprint-form-authors.authors.permissions"}} - - - - -
-
- {{t "components.preprint-form-authors.authors.citation"}} - - - - -
-
-
- - - {{!CONTRIBUTOR NAME - XS Screen}} - {{#if contrib.unregisteredContributor}} - {{contrib.unregisteredContributor}} - {{else}} - {{contrib.users.fullName}} - {{/if}} - - - - -
-
- - -
- {{#if (and (not (contributor-is-current-user contrib currentUser)) isAdmin (and canEdit (min-admins contrib contributors authorModification)))}} - {{t "components.preprint-form-authors.authors.permissions"}}: - - {{else}} -
- {{t "components.preprint-form-authors.authors.permissions"}}: {{permission-map contrib.permission}} -
- {{/if}} -
-
-
- {{t "components.preprint-form-authors.authors.in_citation"}}: - -
-
- -
-
-
- - {{/if}} - -{{#if (not editing)}} -
-
- {{#if contributors}} -
    - {{#each contributors as |c| }} -
  • {{c.users.fullName}}
  • - {{/each}} -
- {{/if}} - -
-
-{{/if}} From 300703c9bf844b24311789a96d828a3f015afe5d Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 13:59:40 -0500 Subject: [PATCH 07/10] Remove unused adapters --- app/adapters/case.js | 52 ------------------------------ app/adapters/group.js | 4 --- app/adapters/parameter-alias.js | 28 ----------------- app/adapters/parameter-stub.js | 28 ----------------- app/adapters/parameter.js | 56 --------------------------------- app/adapters/section.js | 24 -------------- app/adapters/widget.js | 20 ------------ app/adapters/workflow.js | 24 -------------- 8 files changed, 236 deletions(-) delete mode 100644 app/adapters/case.js delete mode 100644 app/adapters/group.js delete mode 100644 app/adapters/parameter-alias.js delete mode 100644 app/adapters/parameter-stub.js delete mode 100644 app/adapters/parameter.js delete mode 100644 app/adapters/section.js delete mode 100644 app/adapters/widget.js delete mode 100644 app/adapters/workflow.js diff --git a/app/adapters/case.js b/app/adapters/case.js deleted file mode 100644 index 7e477c04..00000000 --- a/app/adapters/case.js +++ /dev/null @@ -1,52 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - // Polyfill queryRecord - queryRecord(store, type, query) { - const url = `${this.buildURL(type.modelName, null, null, 'queryRecord', query)}/`; - - if (this.sortQueryParams) { - query = this.sortQueryParams(query); - } - - return this.ajax(url, 'GET', { data: query }) - .then(function(result) { - result = result.data; - // hack to fix https://github.com/emberjs/data/issues/3790 - // and https://github.com/emberjs/data/pull/3866 - try { - store.push({ data: null }); - return { data: result || null }; - } catch (e) { - return { data: result || [] }; - } - }, function(result) { - return { - data: null - }; - }); - }, - - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - buildURL(type, id) { - const base = this._super(...arguments); - const url = `${ENV.APP.apiURL}${base}`; - console.log(url); - return url; - } - -}); diff --git a/app/adapters/group.js b/app/adapters/group.js deleted file mode 100644 index 3219b2eb..00000000 --- a/app/adapters/group.js +++ /dev/null @@ -1,4 +0,0 @@ -import ApplicationAdapter from './application'; - -export default ApplicationAdapter.extend({ -}); diff --git a/app/adapters/parameter-alias.js b/app/adapters/parameter-alias.js deleted file mode 100644 index 8e65ddbe..00000000 --- a/app/adapters/parameter-alias.js +++ /dev/null @@ -1,28 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - buildURL(type, id, snapshot, requestType, query) { - const base = this._super(...arguments); - const url = []; - url.push(ENV.APP.apiURL); - url.push(base); - const builtUrl = url.join(''); - return builtUrl; - } - -}); diff --git a/app/adapters/parameter-stub.js b/app/adapters/parameter-stub.js deleted file mode 100644 index cac9588b..00000000 --- a/app/adapters/parameter-stub.js +++ /dev/null @@ -1,28 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - ajax(url, method, hash) { - hash = hash || {}; - hash.headers = hash.headers || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - buildURL(type, id, snapshot, requestType, query) { - const base = this._super(...arguments); - const url = []; - url.push(ENV.APP.apiURL); - url.push(base); - const builtUrl = url.join(''); - return builtUrl; - } - -}); diff --git a/app/adapters/parameter.js b/app/adapters/parameter.js deleted file mode 100644 index bd6a865c..00000000 --- a/app/adapters/parameter.js +++ /dev/null @@ -1,56 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - // Polyfill queryRecord - queryRecord(store, type, query) { - const url = `${this.buildURL(type.modelName, null, null, 'queryRecord', query)}/`; - - console.log(url); - - if (this.sortQueryParams) { - query = this.sortQueryParams(query); - } - - return this.ajax(url, 'GET', { data: query }) - .then(function(result) { - result = result.data; - // hack to fix https://github.com/emberjs/data/issues/3790 - // and https://github.com/emberjs/data/pull/3866 - try { - store.push({ data: null }); - return { data: result || null }; - } catch (e) { - return { data: result || [] }; - } - }, function(result) { - return { - data: null - }; - }); - }, - - buildURL(type, id, snapshot, requestType, query) { - const base = this._super(...arguments); - const url = []; - url.push(ENV.APP.apiURL); - url.push(base); - const builtUrl = url.join(''); - return builtUrl; - } - -}); diff --git a/app/adapters/section.js b/app/adapters/section.js deleted file mode 100644 index a322f2ef..00000000 --- a/app/adapters/section.js +++ /dev/null @@ -1,24 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - buildURL() { - const base = this._super(...arguments); - return `${ENV.APP.apiURL}${base}`; - }, - -}); diff --git a/app/adapters/widget.js b/app/adapters/widget.js deleted file mode 100644 index 80a07d1b..00000000 --- a/app/adapters/widget.js +++ /dev/null @@ -1,20 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - session: Ember.inject.service(), - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - buildURL() { - const base = this._super(...arguments); - return `${ENV.APP.apiURL}${base}`; - }, -}); diff --git a/app/adapters/workflow.js b/app/adapters/workflow.js deleted file mode 100644 index a322f2ef..00000000 --- a/app/adapters/workflow.js +++ /dev/null @@ -1,24 +0,0 @@ -import DS from 'ember-data'; -import ENV from '../config/environment'; - -const { JSONAPIAdapter } = DS; - -export default JSONAPIAdapter.extend({ - - session: Ember.inject.service(), - - ajax(url, method, hash) { - hash = hash || {}; - hash.crossOrigin = true; - hash.xhrFields = { withCredentials: true }; - hash.headers = hash.headers || {}; - hash.headers['X-CSRFTOKEN'] = this.get('session.data.authenticated.csrfToken'); - return this._super(url, method, hash); - }, - - buildURL() { - const base = this._super(...arguments); - return `${ENV.APP.apiURL}${base}`; - }, - -}); From 7d39c9a72b6b032c1dc87d56a69c862f1e60c94d Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 14:25:41 -0500 Subject: [PATCH 08/10] execute eslint --fix --- .eslintrc.yml | 1 - app/components/alpaca-form/component.js | 62 +++--- app/components/section-file-grid/component.js | 6 +- app/components/section-schedule/component.js | 56 +++--- .../section-splash-image/component.js | 2 +- app/controllers/application.js | 4 +- app/controllers/collections/collection/add.js | 5 +- .../collections/collection/edit.js | 66 +++--- .../collections/collection/moderation.js | 22 +- app/controllers/create.js | 2 +- app/router.js | 90 ++++----- app/routes/collections/collection.js | 3 +- app/routes/collections/my-collection.js | 2 +- app/routes/items/item.js | 2 +- app/routes/items/item/edit.js | 2 +- app/routes/signin.js | 8 +- app/routes/signup.js | 14 +- app/utils/custom_form.js | 188 +++++++++--------- package.json | 2 +- yarn.lock | 85 +++++++- 20 files changed, 349 insertions(+), 273 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 08e448fc..12a444a5 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -10,4 +10,3 @@ rules: ember/no-empty-attrs: off ember/no-observers: off ember/closure-actions: off - diff --git a/app/components/alpaca-form/component.js b/app/components/alpaca-form/component.js index adb994b4..167d1ecd 100644 --- a/app/components/alpaca-form/component.js +++ b/app/components/alpaca-form/component.js @@ -2,38 +2,38 @@ import Ember from 'ember'; import formTemplate from '../../utils/custom_form'; export default Ember.Component.extend({ - session: Ember.inject.service(), - store: Ember.inject.service(), - metaDataString: Ember.computed('output', function() { - return JSON.stringify(this.get('output')); - }), - actions: { + session: Ember.inject.service(), + store: Ember.inject.service(), + metaDataString: Ember.computed('output', function() { + return JSON.stringify(this.get('output')); + }), + actions: { - }, - didRender() { - const that = this; - let originalForm = this.get('input'); - let newForm = JSON.parse(JSON.stringify(originalForm)); - if (!originalForm.options) { - newForm['options'] = {}; - } - if (!originalForm['view']) { - newForm['view'] = 'web-edit'; - } - newForm.options.form = { - "buttons": { - "submit": { - "label": "Save Changes to Metadata", - "click": function() { - var value = this.getValue(); - that.set('output', value); - } + }, + didRender() { + const that = this; + const originalForm = this.get('input'); + const newForm = JSON.parse(JSON.stringify(originalForm)); + if (!originalForm.options) { + newForm.options = {}; } - } - }; + if (!originalForm.view) { + newForm.view = 'web-edit'; + } + newForm.options.form = { + buttons: { + submit: { + label: 'Save Changes to Metadata', + click() { + const value = this.getValue(); + that.set('output', value); + } + } + } + }; - $(document).ready(function() { - $("#myAlpacaForm").alpaca(newForm); - }); - } + $(document).ready(function() { + $('#myAlpacaForm').alpaca(newForm); + }); + } }); diff --git a/app/components/section-file-grid/component.js b/app/components/section-file-grid/component.js index 92bdeb8f..50f7d0a5 100644 --- a/app/components/section-file-grid/component.js +++ b/app/components/section-file-grid/component.js @@ -67,7 +67,7 @@ export default Ember.Component.extend({ collection, status: 'approved' }).then((items) => { - this.set('loading', false) + this.set('loading', false); this.set('items', items); })); }); @@ -79,7 +79,7 @@ export default Ember.Component.extend({ const q = this.get('q'); const page_size = this.get('page_size'); // eslint-disable-line camelcase const collection = this.get('collection').id; - this.set('loading', true) + this.set('loading', true); this.get('store').query('item', { q, page, @@ -87,7 +87,7 @@ export default Ember.Component.extend({ collection, status: 'approved' }).then((items) => { - this.set('loading', false) + this.set('loading', false); this.set('items', items); }); }); diff --git a/app/components/section-schedule/component.js b/app/components/section-schedule/component.js index dccd96b5..974da225 100644 --- a/app/components/section-schedule/component.js +++ b/app/components/section-schedule/component.js @@ -104,38 +104,36 @@ export default Ember.Component.extend({ }); } }), - didRender(){ - + didRender() { $('.selected-schedule').each(function(i, obj) { - if(i !== 0){ - $(obj).removeClass('selected-schedule') + if (i !== 0) { + $(obj).removeClass('selected-schedule'); } - }); - - }, - actions: { - toggleFilterOptions() { - $('.edit-filter-modal').toggleClass('hidden'); - }, - applyFilter() { - $('.edit-filter-modal').toggleClass('hidden'); - $('.filter, .filter-remove, .fa-plus, .fa-filter').removeClass('filter-hidden'); - }, - addFilter() { - const filter = this.get('filters'); - filter.pushObject({ id: (filter.length), name: $(`#${event.target.id} :selected`).text() }); - this.set('filters', filter); - }, - removeFilter() { - $(event.target).parent().remove(); + }); }, - getInput(e) { - const filter = this.get('filters'); - if (filter.some(function(o) { return o.name === e; }) || e.replace(/ /g, '') === '') { - return false; + actions: { + toggleFilterOptions() { + $('.edit-filter-modal').toggleClass('hidden'); + }, + applyFilter() { + $('.edit-filter-modal').toggleClass('hidden'); + $('.filter, .filter-remove, .fa-plus, .fa-filter').removeClass('filter-hidden'); + }, + addFilter() { + const filter = this.get('filters'); + filter.pushObject({ id: (filter.length), name: $(`#${event.target.id} :selected`).text() }); + this.set('filters', filter); + }, + removeFilter() { + $(event.target).parent().remove(); + }, + getInput(e) { + const filter = this.get('filters'); + if (filter.some(function(o) { return o.name === e; }) || e.replace(/ /g, '') === '') { + return false; + } + filter.pushObject({ id: (filter.length), name: e }); + this.set('filters', filter); } - filter.pushObject({ id: (filter.length), name: e }); - this.set('filters', filter); } -} }); diff --git a/app/components/section-splash-image/component.js b/app/components/section-splash-image/component.js index 415d4376..ef37453b 100644 --- a/app/components/section-splash-image/component.js +++ b/app/components/section-splash-image/component.js @@ -12,7 +12,7 @@ export default Ember.Component.extend({ const height = this.get('layout.height') ? this.get('layout.height') : '300px'; return `background: ${url} no-repeat left center; ` + 'background-size: cover; ' + - `height: ${height};` + + `height: ${height};` + `background-position: ${this.get('layout.position')};`; }) }); diff --git a/app/controllers/application.js b/app/controllers/application.js index 9d8b639f..76c470e9 100644 --- a/app/controllers/application.js +++ b/app/controllers/application.js @@ -3,8 +3,8 @@ import Ember from 'ember'; export default Ember.Controller.extend({ session: Ember.inject.service(), - breadCrumb: "Home", - breadCrumbPath: "index", + breadCrumb: 'Home', + breadCrumbPath: 'index', init() { this._super(); window.addEventListener('scroll', function() { diff --git a/app/controllers/collections/collection/add.js b/app/controllers/collections/collection/add.js index 988cbbb4..48cdc46a 100644 --- a/app/controllers/collections/collection/add.js +++ b/app/controllers/collections/collection/add.js @@ -51,7 +51,6 @@ export default Ember.Controller.extend({ }, async submit() { - const node = this.get('store').createRecord('node'); node.set('category', 'other'); node.set('title', 'Created by collections submission form.'); @@ -70,7 +69,7 @@ export default Ember.Controller.extend({ const item = this.get('item'); item.set('collection', this.get('collection')); item.set('kind', 'repository'); - item.set('status','pending'); + item.set('status', 'pending'); item.set('metadata', this.get('metadata')); xhr.onreadystatechange = () => { if (xhr.readyState === 4 && xhr.status >= 200 && xhr.status < 300) { @@ -103,7 +102,7 @@ export default Ember.Controller.extend({ byteNumbers[i] = binaryData.charCodeAt(i); } const byteArray = new Uint8Array(byteNumbers); - const blob = new Blob([byteArray], {type: contentType}); + const blob = new Blob([byteArray], { type: contentType }); xhr.send(blob); } } diff --git a/app/controllers/collections/collection/edit.js b/app/controllers/collections/collection/edit.js index 0989484b..c21c33f1 100644 --- a/app/controllers/collections/collection/edit.js +++ b/app/controllers/collections/collection/edit.js @@ -25,36 +25,36 @@ export default Ember.Controller.extend({ return []; }), actions: { - addModerator(guid) { - const collection = this.get('model'); - this.store.query('user', { - 'username': guid - }).then((users) => { - collection.get('moderators').pushObject(users.get('firstObject')); - this.set('newModeratorGuid', ''); - collection.save(); - }); - }, - removeModerator(user) { - const collection = this.get('model'); - collection.get('moderators').removeObject(user); - collection.save(); - }, - addAdmin(guid) { - const collection = this.get('model'); - this.store.query('user', { - 'username': guid - }).then((users) => { - collection.get('admins').pushObject(users.get('firstObject')); - this.set('newAdminGuid', ''); - collection.save(); - }); - }, - removeAdmin(user) { - const collection = this.get('model'); - collection.get('admins').removeObject(user); - collection.save(); - }, + addModerator(guid) { + const collection = this.get('model'); + this.store.query('user', { + username: guid + }).then((users) => { + collection.get('moderators').pushObject(users.get('firstObject')); + this.set('newModeratorGuid', ''); + collection.save(); + }); + }, + removeModerator(user) { + const collection = this.get('model'); + collection.get('moderators').removeObject(user); + collection.save(); + }, + addAdmin(guid) { + const collection = this.get('model'); + this.store.query('user', { + username: guid + }).then((users) => { + collection.get('admins').pushObject(users.get('firstObject')); + this.set('newAdminGuid', ''); + collection.save(); + }); + }, + removeAdmin(user) { + const collection = this.get('model'); + collection.get('admins').removeObject(user); + collection.save(); + }, showEdit () { this.set('editMode', true); }, @@ -84,17 +84,17 @@ export default Ember.Controller.extend({ this.set('model.settings', jsonSettings); }, updateFormSettings (jsonSettings) { - this.set('model.submissionSettings', jsonSettings); + this.set('model.submissionSettings', jsonSettings); }, updateItemViewSettings (jsonSettings) { - this.set('model.detailViewSettings', jsonSettings); + this.set('model.detailViewSettings', jsonSettings); }, setCollectionType(ev) { this.set('model.type', ev.target.value); }, saveChanges() { // TODO: remove componentNames validation when we start supporting dynamically loaded components - const componentNames = ['section-contributors','section-copyright','section-file-grid','section-hero', + const componentNames = ['section-contributors', 'section-copyright', 'section-file-grid', 'section-hero', 'section-item-table', 'section-landing-board', 'section-landing-default', 'section-landing-info', 'section-landing-list', 'section-menu', 'section-paragraph', 'section-schedule', 'section-splash-image', 'section-sponsors', 'section-title']; diff --git a/app/controllers/collections/collection/moderation.js b/app/controllers/collections/collection/moderation.js index 318996c2..64971608 100644 --- a/app/controllers/collections/collection/moderation.js +++ b/app/controllers/collections/collection/moderation.js @@ -1,17 +1,17 @@ import Ember from 'ember'; export default Ember.Controller.extend({ - store: Ember.inject.service(), - session: Ember.inject.service(), - actions: { - approveItem(item) { - item.set('status', 'approved'); - item.save(); + store: Ember.inject.service(), + session: Ember.inject.service(), + actions: { + approveItem(item) { + item.set('status', 'approved'); + item.save(); + }, + rejectItem(item) { + item.set('status', 'rejected'); + item.save(); + }, }, - rejectItem(item) { - item.set('status', 'rejected'); - item.save(); - }, - }, }); diff --git a/app/controllers/create.js b/app/controllers/create.js index a09d63b6..0e42280d 100644 --- a/app/controllers/create.js +++ b/app/controllers/create.js @@ -1,6 +1,6 @@ import Ember from 'ember'; - export default Ember.Controller.extend({ +export default Ember.Controller.extend({ moderationStyle: false, collectionType: 'repository', submissionStyle: true, diff --git a/app/router.js b/app/router.js index 1093543c..ee92837a 100644 --- a/app/router.js +++ b/app/router.js @@ -8,51 +8,51 @@ const Router = Ember.Router.extend({ // eslint-disable-next-line array-callback-return Router.map(function () { - this.route('index', { - path: '' - }); - this.route('activities', { - path: 'activities' - }); - this.route('explore', { - path: 'explore' - }); - this.route('search', { - path: 'search' - }); - this.route('items', { - path: 'items' - }, function () { - this.route('item', { - path: ':item_id' - }, function() { - this.route('edit'); - }); - }); - this.route('collections', { - path: 'collections' - }, function () { - this.route('my-collection', { - path: 'my-collection' - }); - this.route('collection', { - path: ':collection_id' - }, function () { - this.route('submissions'); - this.route('browse'); - this.route('edit'); - this.route('add'); - this.route('moderation'); - }); - this.route('search'); - this.route('browse'); - }); - this.route('create'); - this.route('not-found', { - path: '/*path' - }); - this.route('signup'); - this.route('signin'); + this.route('index', { + path: '' + }); + this.route('activities', { + path: 'activities' + }); + this.route('explore', { + path: 'explore' + }); + this.route('search', { + path: 'search' + }); + this.route('items', { + path: 'items' + }, function () { + this.route('item', { + path: ':item_id' + }, function() { + this.route('edit'); + }); + }); + this.route('collections', { + path: 'collections' + }, function () { + this.route('my-collection', { + path: 'my-collection' + }); + this.route('collection', { + path: ':collection_id' + }, function () { + this.route('submissions'); + this.route('browse'); + this.route('edit'); + this.route('add'); + this.route('moderation'); + }); + this.route('search'); + this.route('browse'); + }); + this.route('create'); + this.route('not-found', { + path: '/*path' + }); + this.route('signup'); + this.route('signin'); }); export default Router; diff --git a/app/routes/collections/collection.js b/app/routes/collections/collection.js index 6218f33e..d43ffdbb 100644 --- a/app/routes/collections/collection.js +++ b/app/routes/collections/collection.js @@ -3,8 +3,7 @@ import Ember from 'ember'; export default Ember.Route.extend({ model(params) { - - return this.store.findRecord('collection', params.collection_id, {reload: true}); + return this.store.findRecord('collection', params.collection_id, { reload: true }); }, afterModel(model) { diff --git a/app/routes/collections/my-collection.js b/app/routes/collections/my-collection.js index c8077be0..426a2541 100644 --- a/app/routes/collections/my-collection.js +++ b/app/routes/collections/my-collection.js @@ -18,7 +18,7 @@ export default Ember.Route.extend({ filter: { createdBy: this.get('session.session.content.authenticated.user.username') } - }).then((myCollections) => { + }).then((myCollections) => { return Ember.RSVP.hash({ collections: myCollections }); diff --git a/app/routes/items/item.js b/app/routes/items/item.js index 5db0f6ba..0821a700 100644 --- a/app/routes/items/item.js +++ b/app/routes/items/item.js @@ -24,7 +24,7 @@ export default Ember.Route.extend({ }; let collectionTitle = model.item.get('collection.title'); const collectionId = model.item.get('collection.id'); - collectionTitle = collectionTitle ? collectionTitle : 'Collection ' + collectionId; + collectionTitle = collectionTitle || `Collection ${collectionId}`; const collectionCrumb = { title: collectionTitle, path: 'collections.collection', diff --git a/app/routes/items/item/edit.js b/app/routes/items/item/edit.js index 8ba21624..b3ea7284 100644 --- a/app/routes/items/item/edit.js +++ b/app/routes/items/item/edit.js @@ -4,7 +4,7 @@ export default Route.extend({ collection: '', item: '', model() { - this.set('item', this.modelFor('items.item')['item']); + this.set('item', this.modelFor('items.item').item); return this.modelFor('items.item'); }, actions: { diff --git a/app/routes/signin.js b/app/routes/signin.js index a86594fc..7dfbe069 100644 --- a/app/routes/signin.js +++ b/app/routes/signin.js @@ -1,9 +1,9 @@ import Route from '@ember/routing/route'; export default Route.extend({ - actions: { - logIn() { - return true; + actions: { + logIn() { + return true; + } } - } }); diff --git a/app/routes/signup.js b/app/routes/signup.js index 783a58e1..a7c833d0 100644 --- a/app/routes/signup.js +++ b/app/routes/signup.js @@ -1,12 +1,12 @@ import Route from '@ember/routing/route'; export default Route.extend({ - model() { - return this.store.createRecord('user'); - }, - actions: { - createUser() { - this.get('model').save(); + model() { + return this.store.createRecord('user'); + }, + actions: { + createUser() { + this.get('model').save(); + } } - } }); diff --git a/app/utils/custom_form.js b/app/utils/custom_form.js index 0c28083b..9b71c70e 100644 --- a/app/utils/custom_form.js +++ b/app/utils/custom_form.js @@ -1,98 +1,98 @@ export default { - "schema": { - "type": "object", - "properties": { - "email": { - "type": "string", - "required": false - }, - "password": { - "type": "string", - "required": false, - "pattern": {} - }, - "file": { - "type": "string", - "required": false - }, - "check": { - "type": "boolean", - "required": false, - "default": true - } + schema: { + type: 'object', + properties: { + email: { + type: 'string', + required: false + }, + password: { + type: 'string', + required: false, + pattern: {} + }, + file: { + type: 'string', + required: false + }, + check: { + type: 'boolean', + required: false, + default: true + } + }, + required: false }, - "required": false - }, - "options": { - "fields": { - "email": { - "type": "text", - "label": "Email Address", - "helpers": [], - "validate": true, - "disabled": false, - "showMessages": true, - "renderButtons": true, - "data": {}, - "attributes": {}, - "allowOptionalEmpty": true, - "autocomplete": false, - "disallowEmptySpaces": false, - "disallowOnlyEmptySpaces": false - }, - "password": { - "type": "password", - "label": "Password", - "helpers": [], - "validate": true, - "disabled": false, - "showMessages": true, - "renderButtons": true, - "data": {}, - "attributes": {}, - "allowOptionalEmpty": true, - "autocomplete": false, - "disallowEmptySpaces": false, - "disallowOnlyEmptySpaces": false - }, - "file": { - "type": "file", - "label": "File Upload", - "helpers": [], - "validate": true, - "disabled": false, - "showMessages": true, - "renderButtons": true, - "data": {}, - "attributes": {}, - "allowOptionalEmpty": true, - "autocomplete": false, - "disallowEmptySpaces": false, - "disallowOnlyEmptySpaces": false - }, - "check": { - "type": "checkbox", - "rightLabel": "Sign me up for the News Letter!", - "label": "Newsletter", - "helpers": [], - "validate": true, - "disabled": false, - "showMessages": true, - "renderButtons": true - } + options: { + fields: { + email: { + type: 'text', + label: 'Email Address', + helpers: [], + validate: true, + disabled: false, + showMessages: true, + renderButtons: true, + data: {}, + attributes: {}, + allowOptionalEmpty: true, + autocomplete: false, + disallowEmptySpaces: false, + disallowOnlyEmptySpaces: false + }, + password: { + type: 'password', + label: 'Password', + helpers: [], + validate: true, + disabled: false, + showMessages: true, + renderButtons: true, + data: {}, + attributes: {}, + allowOptionalEmpty: true, + autocomplete: false, + disallowEmptySpaces: false, + disallowOnlyEmptySpaces: false + }, + file: { + type: 'file', + label: 'File Upload', + helpers: [], + validate: true, + disabled: false, + showMessages: true, + renderButtons: true, + data: {}, + attributes: {}, + allowOptionalEmpty: true, + autocomplete: false, + disallowEmptySpaces: false, + disallowOnlyEmptySpaces: false + }, + check: { + type: 'checkbox', + rightLabel: 'Sign me up for the News Letter!', + label: 'Newsletter', + helpers: [], + validate: true, + disabled: false, + showMessages: true, + renderButtons: true + } + }, + focus: false, + type: 'object', + helpers: [], + validate: true, + disabled: false, + showMessages: true, + collapsible: false, + legendStyle: 'button' }, - "focus": false, - "type": "object", - "helpers": [], - "validate": true, - "disabled": false, - "showMessages": true, - "collapsible": false, - "legendStyle": "button" - }, - "data": { - "email": "Joe Smith", - "password": "MyPassword" - }, - "view": "web-edit" + data: { + email: 'Joe Smith', + password: 'MyPassword' + }, + view: 'web-edit' }; diff --git a/package.json b/package.json index a5c6b2af..b28e2e55 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "ember-toastr": "^1.7.0", "ember-truncate-text": "^0.0.1", "ember-truth-helpers": "1.3.0", - "eslint": "^4.1.1", + "eslint": "^4.16.0", "eslint-config-airbnb-base": "^11.2.0", "eslint-config-cos-ember": "^0.5.0", "eslint-plugin-import": "^2.6.1", diff --git a/yarn.lock b/yarn.lock index 054dfc38..ac16c969 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,7 @@ ember-i18n "5.0.1" ember-metrics "0.10.0" ember-moment "7.3.1" + ember-radio-buttons "4.0.3" ember-simple-auth "^1.3.0" ember-sinon "0.7.0" ember-sinon-qunit "1.6.0" @@ -155,6 +156,10 @@ acorn@^5.0.3, acorn@^5.1.1: version "5.2.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" +acorn@^5.2.1: + version "5.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102" + after@0.8.1: version "0.8.1" resolved "https://registry.yarnpkg.com/after/-/after-0.8.1.tgz#ab5d4fb883f596816d3515f8f791c0af486dd627" @@ -181,6 +186,15 @@ ajv@^5.1.0, ajv@^5.2.3: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" +ajv@^5.3.0: + version "5.5.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" + dependencies: + co "^4.6.0" + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -2355,7 +2369,7 @@ debug@2.6.9, debug@^2.1.0, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.4. dependencies: ms "2.0.0" -debug@^3.0.1: +debug@^3.0.1, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -2495,6 +2509,12 @@ doctrine@^2.0.0: esutils "^2.0.2" isarray "^1.0.0" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + dependencies: + esutils "^2.0.2" + domain-browser@~1.1.0: version "1.1.7" resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" @@ -3723,7 +3743,11 @@ eslint-scope@^3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint@^4.0.0, eslint@^4.1.1: +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^4.0.0: version "4.10.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.10.0.tgz#f25d0d7955c81968c2309aa5c9a229e045176bb7" dependencies: @@ -3765,6 +3789,48 @@ eslint@^4.0.0, eslint@^4.1.1: table "^4.0.1" text-table "~0.2.0" +eslint@^4.16.0: + version "4.16.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.16.0.tgz#934ada9e98715e1d7bbfd6f6f0519ed2fab35cc1" + dependencies: + ajv "^5.3.0" + babel-code-frame "^6.22.0" + chalk "^2.1.0" + concat-stream "^1.6.0" + cross-spawn "^5.1.0" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^3.7.1" + eslint-visitor-keys "^1.0.0" + espree "^3.5.2" + esquery "^1.0.0" + esutils "^2.0.2" + file-entry-cache "^2.0.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.0.1" + ignore "^3.3.3" + imurmurhash "^0.1.4" + inquirer "^3.0.6" + is-resolvable "^1.0.0" + js-yaml "^3.9.1" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.3.0" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + require-uncached "^1.0.3" + semver "^5.3.0" + strip-ansi "^4.0.0" + strip-json-comments "~2.0.1" + table "^4.0.1" + text-table "~0.2.0" + espree@^3.5.1: version "3.5.1" resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e" @@ -3772,6 +3838,13 @@ espree@^3.5.1: acorn "^5.1.1" acorn-jsx "^3.0.0" +espree@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" + dependencies: + acorn "^5.2.1" + acorn-jsx "^3.0.0" + esprima-fb@~15001.1001.0-dev-harmony-fb: version "15001.1001.0-dev-harmony-fb" resolved "https://registry.yarnpkg.com/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz#43beb57ec26e8cf237d3dd8b33e42533577f2659" @@ -4335,6 +4408,10 @@ global-prefix@^0.1.4: is-windows "^0.2.0" which "^1.2.12" +globals@^11.0.1: + version "11.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0" + globals@^6.4.0: version "6.4.1" resolved "https://registry.yarnpkg.com/globals/-/globals-6.4.1.tgz#8498032b3b6d1cc81eebc5f79690d8fe29fabf4f" @@ -4960,6 +5037,10 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" From 42299c2c1fae8a25331a456f9f75a2e231ad6840 Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 15:41:00 -0500 Subject: [PATCH 09/10] eslint --fix tests/**, add signin and signup route tests --- tests/.eslintrc.js | 5 +++++ .../routes/collections/collection/item/edit-test.js | 8 ++++---- .../routes/collections/collection/moderation-test.js | 8 ++++---- tests/unit/routes/signin-test.js | 11 +++++++++++ tests/unit/routes/signup-test.js | 11 +++++++++++ 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 tests/.eslintrc.js create mode 100644 tests/unit/routes/signin-test.js create mode 100644 tests/unit/routes/signup-test.js diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js new file mode 100644 index 00000000..fbf25552 --- /dev/null +++ b/tests/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + env: { + embertest: true + } +}; diff --git a/tests/unit/routes/collections/collection/item/edit-test.js b/tests/unit/routes/collections/collection/item/edit-test.js index 0d7e5076..66c198a1 100644 --- a/tests/unit/routes/collections/collection/item/edit-test.js +++ b/tests/unit/routes/collections/collection/item/edit-test.js @@ -1,11 +1,11 @@ import { moduleFor, test } from 'ember-qunit'; moduleFor('route:collections/collection/item/edit', 'Unit | Route | collections/collection/item/edit', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] + // Specify the other units that are required for this test. + // needs: ['controller:foo'] }); test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + const route = this.subject(); + assert.ok(route); }); diff --git a/tests/unit/routes/collections/collection/moderation-test.js b/tests/unit/routes/collections/collection/moderation-test.js index e0dea890..9afe1bd1 100644 --- a/tests/unit/routes/collections/collection/moderation-test.js +++ b/tests/unit/routes/collections/collection/moderation-test.js @@ -1,11 +1,11 @@ import { moduleFor, test } from 'ember-qunit'; moduleFor('route:collections/collection/moderation', 'Unit | Route | collections/collection/moderation', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] + // Specify the other units that are required for this test. + // needs: ['controller:foo'] }); test('it exists', function(assert) { - let route = this.subject(); - assert.ok(route); + const route = this.subject(); + assert.ok(route); }); diff --git a/tests/unit/routes/signin-test.js b/tests/unit/routes/signin-test.js new file mode 100644 index 00000000..af32b86c --- /dev/null +++ b/tests/unit/routes/signin-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:signin', 'Unit | Route | signin', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + const route = this.subject(); + assert.ok(route); +}); diff --git a/tests/unit/routes/signup-test.js b/tests/unit/routes/signup-test.js new file mode 100644 index 00000000..216cc8ee --- /dev/null +++ b/tests/unit/routes/signup-test.js @@ -0,0 +1,11 @@ +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('route:signup', 'Unit | Route | signup', { + // Specify the other units that are required for this test. + // needs: ['controller:foo'] +}); + +test('it exists', function(assert) { + const route = this.subject(); + assert.ok(route); +}); From 88a3f0ee8bd5442ec98d5f17d8dfb4537e7d3cd4 Mon Sep 17 00:00:00 2001 From: Cameron Blandford Date: Fri, 2 Feb 2018 16:44:59 -0500 Subject: [PATCH 10/10] Remove all eslint errors --- .eslintignore | 1 + .eslintrc.yml | 7 +++ app/components/alpaca-form/component.js | 4 -- .../new-navbar-auth-dropdown/component.js | 46 ++++++++++--------- app/components/new-osf-navbar/component.js | 34 ++++++-------- .../section-contributors/component.js | 1 - .../section-item-table/component.js | 4 +- app/components/section-menu/component.js | 13 +++--- app/controllers/collections/collection/add.js | 2 +- app/controllers/create.js | 6 +-- app/routes/collections/collection/add.js | 5 +- .../collections/collection/submissions.js | 8 ++-- app/routes/collections/my-collection.js | 2 +- app/routes/search.js | 4 +- app/serializers/application.js | 1 - 15 files changed, 67 insertions(+), 71 deletions(-) diff --git a/.eslintignore b/.eslintignore index 94be88a9..a9527b3b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ coverage dist docs tmp +app/index.html diff --git a/.eslintrc.yml b/.eslintrc.yml index 12a444a5..9c99d335 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -10,3 +10,10 @@ rules: ember/no-empty-attrs: off ember/no-observers: off ember/closure-actions: off + ember/avoid-leaking-state-in-components: off + ember/order-in-components: off + ember/order-in-controllers: off + ember/order-in-models: off + ember/order-in-routes: off + max-len: off + no-mixed-operators: off diff --git a/app/components/alpaca-form/component.js b/app/components/alpaca-form/component.js index 167d1ecd..6b450224 100644 --- a/app/components/alpaca-form/component.js +++ b/app/components/alpaca-form/component.js @@ -1,5 +1,4 @@ import Ember from 'ember'; -import formTemplate from '../../utils/custom_form'; export default Ember.Component.extend({ session: Ember.inject.service(), @@ -7,9 +6,6 @@ export default Ember.Component.extend({ metaDataString: Ember.computed('output', function() { return JSON.stringify(this.get('output')); }), - actions: { - - }, didRender() { const that = this; const originalForm = this.get('input'); diff --git a/app/components/new-navbar-auth-dropdown/component.js b/app/components/new-navbar-auth-dropdown/component.js index a086e490..f393b961 100644 --- a/app/components/new-navbar-auth-dropdown/component.js +++ b/app/components/new-navbar-auth-dropdown/component.js @@ -27,31 +27,22 @@ export default Ember.Component.extend(AnalyticsMixin, { classNames: ['dropdown-submenu'], redirectUrl: null, subMenuOpenState: false, + + // TODO: These parameters are defined in osf settings.py; make sure ember config matches. + allowLogin: true, + enableInstitutions: true, + user: null, + notAuthenticated: Ember.computed.not('session.isAuthenticated'), fullName: Ember.computed('session', function() { return `${this.get('session.session.content.authenticated.user.first-name')} ${this.get('session.session.content.authenticated.user.last-name')}`; }), - - /** - * The URL to use for signup. May be overridden, eg for special campaign pages - * - * @property signupUrl - * @type {String} - */ - signupUrl: `${config.OSF.url}register`, - gravatarUrl: Ember.computed('user', function() { const imgLink = this.get('user.links.profile_image'); return imgLink ? `${imgLink}&s=25` : ''; }), - host: config.OSF.url, - user: null, - _loadCurrentUser() { - this.get('currentUser') - .load() - .then(user => this.set('user', user)); - }, + init() { this._super(...arguments); // TODO: React to changes in service/ event? @@ -59,9 +50,7 @@ export default Ember.Component.extend(AnalyticsMixin, { this._loadCurrentUser(); } }, - // TODO: These parameters are defined in osf settings.py; make sure ember config matches. - allowLogin: true, - enableInstitutions: true, + actions: { toggleSubMenu(e) { this.toggleProperty('subMenuOpenState'); @@ -73,7 +62,22 @@ export default Ember.Component.extend(AnalyticsMixin, { const query = redirectUrl ? `?${Ember.$.param({ next_url: redirectUrl })}` : ''; // TODO: May not work well if logging out from page that requires login- check? this.get('session').invalidate() - .then(() => window.location.href = `${config.OSF.url}logout/${query}`); + .then(() => { window.location.href = `${config.OSF.url}logout/${query}`; }); }, - } + }, + + _loadCurrentUser() { + this.get('currentUser') + .load() + .then(user => this.set('user', user)); + }, + + /** + * The URL to use for signup. May be overridden, eg for special campaign pages + * + * @property signupUrl + * @type {String} + */ + signupUrl: `${config.OSF.url}register`, + host: config.OSF.url, }); diff --git a/app/components/new-osf-navbar/component.js b/app/components/new-osf-navbar/component.js index f67f8c42..f4f46bc4 100644 --- a/app/components/new-osf-navbar/component.js +++ b/app/components/new-osf-navbar/component.js @@ -8,7 +8,8 @@ import Ember from 'ember'; */ /** - * Display the new OSF navbar - features primary navigation to toggle between services - HOME, PREPRINTS, REGISTRIES, and MEETINGS, + * Display the new OSF navbar - features primary navigation to toggle between services - + * HOME, PREPRINTS, REGISTRIES, and MEETINGS, * and secondary navigation links for each particular service. * * Sample usage: @@ -36,17 +37,7 @@ export default Ember.Component.extend(AnalyticsMixin, { name: 'Search', type: 'link-to', route: 'search' - }, - // { - // name: 'My Collection', - // type: 'link-to', - // route: 'collections.my-collection' - // }, - // { - // name: 'Support', - // type: 'link', - // href: 'https://osf.io/support/' - // }, + } ], session: Ember.inject.service(), @@ -62,16 +53,19 @@ export default Ember.Component.extend(AnalyticsMixin, { return appName.toUpperCase(); }), currentServiceLink: Ember.computed('currentService', function() { - const serviceMapping = { - HOME: 'osfHome', - PREPRINTS: 'preprintsHome', - REGISTRIES: 'registriesHome', - MEETINGS: 'meetingsHome', - COLLECTIONS: 'collectionsHome' - }; - const service = this.get('currentService'); + // const serviceMapping = { + // HOME: 'osfHome', + // PREPRINTS: 'preprintsHome', + // REGISTRIES: 'registriesHome', + // MEETINGS: 'meetingsHome', + // COLLECTIONS: 'collectionsHome' + // }; + // const service = this.get('currentService'); return '/'; }), + init() { + this._super(...arguments); + }, actions: { // Toggles whether search bar is displayed (for searching OSF) toggleSearch() { diff --git a/app/components/section-contributors/component.js b/app/components/section-contributors/component.js index f03bff03..28c3f6ce 100644 --- a/app/components/section-contributors/component.js +++ b/app/components/section-contributors/component.js @@ -1,6 +1,5 @@ import Ember from 'ember'; import _ from 'lodash'; -import ENV from '../../config/environment'; export default Ember.Component.extend({ store: Ember.inject.service(), diff --git a/app/components/section-item-table/component.js b/app/components/section-item-table/component.js index bef4c0bf..fe6c93be 100644 --- a/app/components/section-item-table/component.js +++ b/app/components/section-item-table/component.js @@ -117,14 +117,14 @@ export default Ember.Component.extend({ if (this.get('nextPageAvailable')) { this.send('loadPage', this.get('pageNumber') + 1); } else { - console.log('you are already on the last page'); + // console.log('you are already on the last page'); } }, prevPage() { if (this.get('previousPageAvailable')) { this.send('loadPage', this.get('pageNumber') - 1); } else { - console.log('you are already on the first page'); + // console.log('you are already on the first page'); } } } diff --git a/app/components/section-menu/component.js b/app/components/section-menu/component.js index 4ce3f425..da5e1e30 100644 --- a/app/components/section-menu/component.js +++ b/app/components/section-menu/component.js @@ -13,16 +13,16 @@ function animate(propertySetter, start, end, speed, units, animationCompletedCal // Should be in all modern browsers now. // We could run a check and if need be use `Date.now()`. - const start_time = performance.now(); + const startTime = performance.now(); const change = end - start; const duration = Math.abs(change * speed) + 1000; (function step() { - const time_now = performance.now(); - const elapsed_time = time_now - start_time; - requestAnimationFrame(function(ts) { // requestAnimationFrame() === Butter. - propertySetter(start + change * cosPow6Intg(elapsed_time / duration) + units); - if (elapsed_time >= duration) { + const timeNow = performance.now(); + const elapsedTime = timeNow - startTime; + requestAnimationFrame(function() { // requestAnimationFrame() === Butter. + propertySetter(start + change * cosPow6Intg(elapsedTime / duration) + units); + if (elapsedTime >= duration) { propertySetter(end + units); animationCompletedCallback(); return; @@ -64,6 +64,7 @@ export default Ember.Component.extend({ anchorOffset, 0.2, null, + // eslint-disable-next-line no-undef () => history.pushState({}, document.title, location.pathname + href) ); } diff --git a/app/controllers/collections/collection/add.js b/app/controllers/collections/collection/add.js index 48cdc46a..76b0074e 100644 --- a/app/controllers/collections/collection/add.js +++ b/app/controllers/collections/collection/add.js @@ -65,7 +65,7 @@ export default Ember.Controller.extend({ xhr.withCredentials = false; xhr.setRequestHeader('Authorization', `Bearer ${getToken()}`); - const deferred = Ember.RSVP.defer(); + Ember.RSVP.defer(); const item = this.get('item'); item.set('collection', this.get('collection')); item.set('kind', 'repository'); diff --git a/app/controllers/create.js b/app/controllers/create.js index 0e42280d..5b1fba37 100644 --- a/app/controllers/create.js +++ b/app/controllers/create.js @@ -9,17 +9,17 @@ export default Ember.Controller.extend({ moderationToggled(choice) { this.get('collection').set('moderationRequired', choice); this.set('moderationRequired', choice); - console.log('set moderationRequired value to', choice); + // console.log('set moderationRequired value to', choice); }, typeToggled(choice) { this.get('collection').set('collectionType', choice); this.set('collectionType', choice); - console.log('set collection type to', choice); + // console.log('set collection type to', choice); }, submissionStyleToggled(choice) { this.get('collection').set('anyoneCanSubmit', choice); this.set('submissionStyle', choice); - console.log('set anyoneCanSubmit to', choice); + // console.log('set anyoneCanSubmit to', choice); }, saveCollection () { const collection = this.get('collection'); diff --git a/app/routes/collections/collection/add.js b/app/routes/collections/collection/add.js index c28ec2b4..0fc1f1d3 100644 --- a/app/routes/collections/collection/add.js +++ b/app/routes/collections/collection/add.js @@ -2,16 +2,13 @@ import Ember from 'ember'; export default Ember.Route.extend({ - model(params) { + model() { return Ember.RSVP.hash({ collection: this.modelFor('collections.collection'), item: this.store.createRecord('item') }); }, - afterModel(model, transition) { - }, - setupController(controller, model) { controller.set('collection', model.collection); controller.set('item', model.item); diff --git a/app/routes/collections/collection/submissions.js b/app/routes/collections/collection/submissions.js index 49195bef..be9974e8 100644 --- a/app/routes/collections/collection/submissions.js +++ b/app/routes/collections/collection/submissions.js @@ -16,10 +16,8 @@ export default Ember.Route.extend({ collection }); }, - afterModel(model) { - }, - setupController(controller, data) { - controller.set('collection', data.collection); - controller.set('items', data.items); + setupController(controller, model) { + controller.set('collection', model.collection); + controller.set('items', model.items); } }); diff --git a/app/routes/collections/my-collection.js b/app/routes/collections/my-collection.js index 426a2541..2de7df2e 100644 --- a/app/routes/collections/my-collection.js +++ b/app/routes/collections/my-collection.js @@ -13,7 +13,7 @@ export default Ember.Route.extend({ }]); }, - model(params) { + model() { return this.store.query('collection', { filter: { createdBy: this.get('session.session.content.authenticated.user.username') diff --git a/app/routes/search.js b/app/routes/search.js index 3e649944..c21facd0 100644 --- a/app/routes/search.js +++ b/app/routes/search.js @@ -11,12 +11,12 @@ export default Ember.Route.extend({ } }, actions: { - willTransition(transition) { + willTransition() { this.controllerFor('collections.index').set('loading', true); } }, - model(params, transition) { + model(params, transition) { // eslint-disable-lin no-unused-vars return Ember.RSVP.hash({ collections: this.store.query('item', { q: transition.queryParams.q, diff --git a/app/serializers/application.js b/app/serializers/application.js index cdaf1bbc..451eae79 100644 --- a/app/serializers/application.js +++ b/app/serializers/application.js @@ -1,4 +1,3 @@ -import Ember from 'ember'; import DS from 'ember-data'; const { JSONAPISerializer } = DS;