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 08e448fc..9c99d335 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -10,4 +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/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
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}`;
- },
-
-});
diff --git a/app/components/alpaca-form/component.js b/app/components/alpaca-form/component.js
index adb994b4..6b450224 100644
--- a/app/components/alpaca-form/component.js
+++ b/app/components/alpaca-form/component.js
@@ -1,39 +1,35 @@
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: {
-
- },
- 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);
- }
+ session: Ember.inject.service(),
+ store: Ember.inject.service(),
+ metaDataString: Ember.computed('output', function() {
+ return JSON.stringify(this.get('output'));
+ }),
+ 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/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-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-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/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/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"}}Search {{displayItemType}}
-
{{input class="form-control" value=searchGuid placeholder="Enter guid" enter="enterPressGuid"}} Preview
-
-
- {{#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}} Add Item
- {{/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"}}
-
-
Add
-
-
-
- {{#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 @@
-
- {{description}}
-
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 @@
-
- {{description}}
-
-
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 @@
-
-{{description}}
\ 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}}
- {{choice.label}}
-
-{{/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}}
-
- {{widget.description}}
- {{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 @@
-
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}}
-
-
-
-
-
-
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 @@
-
- {{description}}
-
-
-
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 @@
-
- {{description}}
-
-
-
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}}
-
-
-
-
-
-
- Discard changes
- Save and continue
-
-
-
- {{/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}}
-
- {{widget.description}}
- {{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}}
-
- {{widget.description}}
- {{#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 ' +
- ' ' +
- '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}}
-
-{{#if (not editing)}}
-
-
- {{#if contributors}}
-
- {{#each contributors as |c| }}
- {{c.users.fullName}}
- {{/each}}
-
- {{/if}}
-
-
-
-{{/if}}
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..76b0074e 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.');
@@ -66,11 +65,11 @@ 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');
- 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 80866e54..5b1fba37 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: '',
+export default Ember.Controller.extend({
moderationStyle: false,
collectionType: 'repository',
submissionStyle: true,
@@ -12,17 +9,17 @@ import Ember from 'ember';
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/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/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 c8077be0..2de7df2e 100644
--- a/app/routes/collections/my-collection.js
+++ b/app/routes/collections/my-collection.js
@@ -13,12 +13,12 @@ export default Ember.Route.extend({
}]);
},
- model(params) {
+ model() {
return this.store.query('collection', {
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/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/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/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;
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/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/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.
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.
+
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
-