1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Replaced underscore.js & is.js with lodash.js

This commit is contained in:
Harvey Kandola 2019-03-03 13:10:04 +00:00
parent df8e843bf5
commit 566807bc14
93 changed files with 17379 additions and 2056 deletions

View file

@ -48,11 +48,11 @@ export default Component.extend(ModalMixin, Notifer, {
// get summary of documents and users for each category in space
this.get('categorySvc').getSummary(this.get('space.id')).then((s) => {
c.forEach((cat) => {
let docs = _.where(s, {categoryId: cat.get('id'), type: 'documents'});
let docs = _.filter(s, {categoryId: cat.get('id'), type: 'documents'});
let docCount = 0;
docs.forEach((d) => { docCount = docCount + d.count });
let users = _.where(s, {categoryId: cat.get('id'), type: 'users'});
let users = _.filter(s, {categoryId: cat.get('id'), type: 'users'});
let userCount = 0;
users.forEach((u) => { userCount = userCount + u.count });
@ -62,9 +62,9 @@ export default Component.extend(ModalMixin, Notifer, {
this.get('categorySvc').getUserVisible(this.get('space.id')).then((cm) => {
cm.forEach((cm) => {
let cat = _.findWhere(c, {id: cm.get('id') });
if (is.not.undefined(cat)) {
cat.set('access', is.not.undefined(cat));
let cat = _.find(c, {id: cm.get('id') });
if (!_.isUndefined(cat)) {
cat.set('access', !_.isUndefined(cat));
}
});
});
@ -91,7 +91,7 @@ export default Component.extend(ModalMixin, Notifer, {
let cats = this.get('category');
let cat = cats.findBy('id', id);
if (is.not.undefined(cat)) {
if (!_.isUndefined(cat)) {
cat.set('editMode', val);
}
@ -185,7 +185,7 @@ export default Component.extend(ModalMixin, Notifer, {
// mark those users as selected that have permission to see the current category
perms.forEach((perm) => {
let c = categoryPermissions.findBy('whoId', perm.get('whoId'));
if (is.not.undefined(c)) {
if (!_.isUndefined(c)) {
c.set('selected', true);
}
});

View file

@ -70,7 +70,7 @@ export default Component.extend(AuthMixin, Notifier, {
this.set('spaceLabel', this.get('space.labelId'));
let icon = this.get('space.icon');
if (is.empty(icon)) {
if (_.isEmpty(icon)) {
icon = constants.IconMeta.Apps;
}

View file

@ -138,7 +138,7 @@ export default Component.extend(Notifier, Modals, {
users.forEach((user) => {
let exists = spacePermissions.findBy('whoId', user.get('id'));
if (is.undefined(exists)) {
if (_.isUndefined(exists)) {
filteredUsers.pushObject(user);
}
});
@ -203,7 +203,7 @@ export default Component.extend(Notifier, Modals, {
}
});
if (is.not.undefined(hasEveryone)) {
if (!_.isUndefined(hasEveryone)) {
folder.markAsPublic();
} else {
if (roleCount > 1) {
@ -238,7 +238,7 @@ export default Component.extend(Notifier, Modals, {
let exists = spacePermissions.findBy('whoId', user.get('id'));
if (is.undefined(exists)) {
if (_.isUndefined(exists)) {
spacePermissions.pushObject(this.permissionRecord(constants.WhoType.User, user.get('id'), user.get('fullname')));
this.set('spacePermissions', spacePermissions);
this.send('onSearch');

View file

@ -46,8 +46,8 @@ export default Component.extend(AuthMixin, {
let selectedCategory = '';
categories.forEach((cat)=> {
let summary = _.findWhere(categorySummary, {type: "documents", categoryId: cat.get('id')});
let docCount = is.not.undefined(summary) ? summary.count : 0;
let summary = _.find(categorySummary, {type: "documents", categoryId: cat.get('id')});
let docCount = !_.isUndefined(summary) ? summary.count : 0;
cat.set('docCount', docCount);
if (docCount > 0 && selectedCategory === '') {
selectedCategory = cat.get('id');
@ -56,7 +56,7 @@ export default Component.extend(AuthMixin, {
this.set('categories', categories);
this.set('categoryLinkName', categories.length > 0 ? 'Manage' : 'Add');
this.set('spaceLabel', _.findWhere(this.get('labels'), {id: this.get('space.labelId')}));
this.set('spaceLabel', _.find(this.get('labels'), {id: this.get('space.labelId')}));
schedule('afterRender', () => {
if (this.get('categoryFilter') !== '') {
@ -77,9 +77,9 @@ export default Component.extend(AuthMixin, {
switch (filter) {
case 'category':
allowed = _.pluck(_.where(categoryMembers, {'categoryId': id}), 'documentId');
allowed = _.map(_.filter(categoryMembers, {'categoryId': id}), 'documentId');
docs.forEach((d) => {
if (_.contains(allowed, d.get('id'))) {
if (_.includes(allowed, d.get('id'))) {
filtered.pushObject(d);
}
});
@ -88,9 +88,9 @@ export default Component.extend(AuthMixin, {
break;
case 'uncategorized':
allowed = _.pluck(categoryMembers, 'documentId');
allowed = _.map(categoryMembers, 'documentId');
docs.forEach((d) => {
if (!_.contains(allowed, d.get('id'))) {
if (!_.includes(allowed, d.get('id'))) {
filtered.pushObject(d);
}
});

View file

@ -92,7 +92,7 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
willDestroyElement() {
this._super(...arguments);
if (is.not.null(this.get('dropzone'))) {
if (!_.isNull(this.get('dropzone'))) {
this.get('dropzone').destroy();
this.set('dropzone', null);
}
@ -100,7 +100,7 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
setupImport() {
// already done init?
if (is.not.null(this.get('dropzone'))) {
if (!_.isNull(this.get('dropzone'))) {
this.get('dropzone').destroy();
this.set('dropzone', null);
}
@ -180,7 +180,7 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
e.preventDefault();
let docName = this.get('emptyDocName');
if (is.empty(docName)) {
if (_.isEmpty(docName)) {
this.set('emptyDocNameError', true);
$('#empty-doc-name').focus();
return;
@ -217,14 +217,14 @@ export default Component.extend(ModalMixin, AuthMixin, Notifier, {
e.preventDefault();
let docName = this.get('templateDocName');
if (is.empty(docName)) {
if (_.isEmpty(docName)) {
this.set('templateDocNameError', true);
$('#template-doc-name').focus();
return;
}
let id = this.get('selectedTemplate');
if (is.empty(id)) {
if (_.isEmpty(id)) {
$('#widget-list-picker').addClass('is-invalid');
return;
}