mirror of
https://github.com/documize/community.git
synced 2025-08-05 05:25:27 +02:00
Replaced underscore.js & is.js with lodash.js
This commit is contained in:
parent
df8e843bf5
commit
566807bc14
93 changed files with 17379 additions and 2056 deletions
|
@ -41,7 +41,7 @@ export default AjaxService.extend({
|
|||
let appVersion = headers['x-documize-version'];
|
||||
|
||||
// Unauthorized local API AJAX calls redirect to app root.
|
||||
if (status === 401 && is.not.undefined(appVersion) && is.not.include(window.location.href, '/auth')) {
|
||||
if (status === 401 && !_.isUndefined(appVersion) && !_.includes(window.location.href, '/auth')) {
|
||||
this.get('localStorage').clearAll();
|
||||
window.location.href = 'auth/login';
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export default AjaxService.extend({
|
|||
this.set('appMeta.valid', false);
|
||||
}
|
||||
|
||||
if (this.get('session.authenticated') && is.not.empty(userUpdate) && is.not.undefined(userUpdate)) {
|
||||
if (this.get('session.authenticated') && !_.isEmpty(userUpdate) && !_.isUndefined(userUpdate)) {
|
||||
let latest = JSON.parse(userUpdate);
|
||||
// Permission change means re-validation.
|
||||
if (!latest.active || user.editor !== latest.editor || user.admin !== latest.admin ||
|
||||
|
|
|
@ -53,7 +53,7 @@ export default Service.extend({
|
|||
this.set('authProvider', constants.AuthProvider.Documize);
|
||||
|
||||
let dbhash;
|
||||
if (is.not.null(document.head.querySelector("[property=dbhash]"))) {
|
||||
if (!_.isNull(document.head.querySelector("[property=dbhash]"))) {
|
||||
dbhash = document.head.querySelector("[property=dbhash]").content;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ export default Service.extend({
|
|||
|
||||
this.get('localStorage').clearAll();
|
||||
return resolve(this);
|
||||
} else if (is.not.include(requestedUrl, '/auth/')) {
|
||||
} else if (!_.includes(requestedUrl, '/auth/')) {
|
||||
this.get('localStorage').storeSessionItem('entryUrl', requestedUrl);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ export default Service.extend({
|
|||
setMetaDescription(description) {
|
||||
$('meta[name=description]').remove();
|
||||
|
||||
if (is.null(description) || is.undefined(description)) {
|
||||
if (_.isNull(description) || _.isUndefined(description)) {
|
||||
description = this.get('sessionService.appMeta.message');
|
||||
}
|
||||
},
|
||||
|
@ -44,7 +44,7 @@ export default Service.extend({
|
|||
scrollTo(id) {
|
||||
schedule('afterRender', () => {
|
||||
let elem = $(id).offset();
|
||||
if (is.undefined(elem)) return;
|
||||
if (_.isUndefined(elem)) return;
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: elem.top
|
||||
|
|
|
@ -36,7 +36,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('category', obj);
|
||||
|
@ -53,7 +53,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('category', obj);
|
||||
|
@ -91,7 +91,7 @@ export default BaseService.extend({
|
|||
}).then((response) => {
|
||||
// return response;
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('category-permission', obj);
|
||||
|
@ -108,7 +108,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
|
|
@ -47,7 +47,7 @@ export default Service.extend({
|
|||
let documents = ArrayProxy.create({
|
||||
content: A([])
|
||||
});
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
documents = response.map((doc) => {
|
||||
let data = this.get('store').normalize('document', doc);
|
||||
|
@ -115,7 +115,7 @@ export default Service.extend({
|
|||
return this.get('ajax').request(`documents/${documentId}/pages`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
let pages = [];
|
||||
|
||||
pages = response.map((page) => {
|
||||
|
@ -218,7 +218,7 @@ export default Service.extend({
|
|||
return this.get('ajax').request(`documents/${documentId}/pages?content=0`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
let data = [];
|
||||
data = response.map((obj) => {
|
||||
|
@ -288,7 +288,7 @@ export default Service.extend({
|
|||
return this.get('ajax').request(`sections/targets`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
let data = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
|
@ -335,7 +335,7 @@ export default Service.extend({
|
|||
} else {
|
||||
let id = this.get('storageSvc').getSessionItem('anonId');
|
||||
|
||||
if (is.not.null(id) && is.not.undefined(id) && id.length >= 16) {
|
||||
if (!_.isNull(id) && !_.isUndefined(id) && id.length >= 16) {
|
||||
userId = id;
|
||||
} else {
|
||||
userId = stringUtil.anonUserId();
|
||||
|
@ -443,7 +443,7 @@ export default Service.extend({
|
|||
let userHasChangeAwaitingReview = false;
|
||||
let userHasChangeRejected = false;
|
||||
|
||||
if (is.null(source) || is.undefined(source)) source = "";
|
||||
if (_.isNull(source) || _.isUndefined(source)) source = "";
|
||||
|
||||
return this.get('ajax').request(`fetch/page/${documentId}?source=${source}`, {
|
||||
method: 'GET'
|
||||
|
|
|
@ -102,7 +102,7 @@ export default BaseService.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('folder', obj);
|
||||
|
@ -125,7 +125,7 @@ export default BaseService.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
obj.id = 'sp-' + obj.id;
|
||||
|
@ -156,7 +156,7 @@ export default BaseService.extend({
|
|||
|
||||
// Current folder caching
|
||||
setCurrentFolder(folder) {
|
||||
if (is.undefined(folder) || is.null(folder)) {
|
||||
if (_.isUndefined(folder) || _.isNull(folder)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ export default BaseService.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('folder', obj);
|
||||
|
|
|
@ -35,7 +35,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('group', obj);
|
||||
|
|
|
@ -26,7 +26,7 @@ export default Service.extend({
|
|||
|
||||
boot() {
|
||||
return new EmberPromise((resolve, reject) => {
|
||||
if (is.not.undefined(this.get('keycloak')) && is.not.null(this.get('keycloak')) ) {
|
||||
if (!_.isUndefined(this.get('keycloak')) && !_.isNull(this.get('keycloak')) ) {
|
||||
resolve(this.get('keycloak'));
|
||||
return;
|
||||
}
|
||||
|
@ -94,12 +94,12 @@ export default Service.extend({
|
|||
return {
|
||||
domain: '',
|
||||
token: this.get('keycloak').token,
|
||||
remoteId: is.null(profile.id) || is.undefined(profile.id) ? profile.email: profile.id,
|
||||
email: is.null(profile.email) || is.undefined(profile.email) ? '': profile.email,
|
||||
username: is.null(profile.username) || is.undefined(profile.username) ? '': profile.username,
|
||||
firstname: is.null(profile.firstName) || is.undefined(profile.firstName) ? profile.username: profile.firstName,
|
||||
lastname: is.null(profile.lastName) || is.undefined(profile.lastName) ? profile.username: profile.lastName,
|
||||
enabled: is.null(profile.enabled) || is.undefined(profile.enabled) ? true: profile.enabled
|
||||
remoteId: _.isNull(profile.id) || _.isUndefined(profile.id) ? profile.email: profile.id,
|
||||
email: _.isNull(profile.email) || _.isUndefined(profile.email) ? '': profile.email,
|
||||
username: _.isNull(profile.username) || _.isUndefined(profile.username) ? '': profile.username,
|
||||
firstname: _.isNull(profile.firstName) || _.isUndefined(profile.firstName) ? profile.username: profile.firstName,
|
||||
lastname: _.isNull(profile.lastName) || _.isUndefined(profile.lastName) ? profile.username: profile.lastName,
|
||||
enabled: _.isNull(profile.enabled) || _.isUndefined(profile.enabled) ? true: profile.enabled
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.null(response)) response = [];
|
||||
if (_.isNull(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('label', obj);
|
||||
|
|
|
@ -84,7 +84,7 @@ export default Service.extend(Notifier, {
|
|||
documentId: a.attributes["data-link-target-document-id"].value,
|
||||
spaceId: a.attributes["data-link-space-id"].value,
|
||||
targetId: a.attributes["data-link-target-id"].value,
|
||||
externalId: is.undefined(a.attributes["data-link-external-id"]) ? '' : a.attributes["data-link-external-id"].value,
|
||||
externalId: _.isUndefined(a.attributes["data-link-external-id"]) ? '' : a.attributes["data-link-external-id"].value,
|
||||
url: a.attributes["href"].value,
|
||||
orphan: false
|
||||
};
|
||||
|
@ -111,8 +111,8 @@ export default Service.extend(Notifier, {
|
|||
let router = this.get('router');
|
||||
let targetFolder = this.get('store').peekRecord('folder', link.spaceId);
|
||||
let targetDocument = this.get('store').peekRecord('document', link.documentId);
|
||||
let folderSlug = is.null(targetFolder) ? "s" : targetFolder.get('slug');
|
||||
let documentSlug = is.null(targetDocument) ? "d" : targetDocument.get('slug');
|
||||
let folderSlug = _.isNull(targetFolder) ? "s" : targetFolder.get('slug');
|
||||
let documentSlug = _.isNull(targetDocument) ? "d" : targetDocument.get('slug');
|
||||
|
||||
// handle section link
|
||||
if (link.linkType === "section" || link.linkType === "tab") {
|
||||
|
|
|
@ -39,7 +39,7 @@ export default Service.extend({
|
|||
return this.get('ajax').request(`pin/${userId}`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
let pins = ArrayProxy.create({ content: A([]) });
|
||||
|
||||
pins = response.map((pin) => {
|
||||
|
@ -93,7 +93,7 @@ export default Service.extend({
|
|||
method: 'POST',
|
||||
data: JSON.stringify(data)
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
let pins = ArrayProxy.create({
|
||||
content: A([])
|
||||
|
|
|
@ -25,7 +25,7 @@ export default Service.extend({
|
|||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
let results = ArrayProxy.create({
|
||||
content: A([])
|
||||
|
|
|
@ -24,7 +24,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('section', obj);
|
||||
|
@ -70,9 +70,9 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let pages = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
if (is.not.null(response) && is.array(response) && response.length > 0) {
|
||||
if (!_.isNull(response) && _.isArray(response) && response.length > 0) {
|
||||
pages = response.map((page) => {
|
||||
let data = this.get('store').normalize('page', page);
|
||||
return this.get('store').push(data);
|
||||
|
@ -119,7 +119,7 @@ export default BaseService.extend({
|
|||
method: 'GET'
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('block', obj);
|
||||
|
|
|
@ -23,13 +23,11 @@ export default SimpleAuthSession.extend({
|
|||
localStorage: service(),
|
||||
folderPermissions: null,
|
||||
currentFolder: null,
|
||||
isMac: false,
|
||||
isMobile: false,
|
||||
|
||||
secureToken: '',
|
||||
hasSecureToken: computed('secureToken', function () {
|
||||
let st = this.get('secureToken');
|
||||
return is.not.null(st) && is.not.undefined(st) && st.length > 0;
|
||||
return !_.isNull(st) && !_.isUndefined(st) && st.length > 0;
|
||||
}),
|
||||
|
||||
hasAccounts: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||
|
@ -51,7 +49,7 @@ export default SimpleAuthSession.extend({
|
|||
}),
|
||||
|
||||
authenticated: computed('session.content.authenticated.user', function () {
|
||||
if (is.null(this.get('session.authenticator')) || this.get('appMeta.secureMode')) return false;
|
||||
if (_.isNull(this.get('session.authenticator')) || this.get('appMeta.secureMode')) return false;
|
||||
return this.get('session.authenticator') !== 'authenticator:anonymous' && this.get('session.content.authenticated.user.id') !== '0';
|
||||
}),
|
||||
|
||||
|
@ -92,7 +90,7 @@ export default SimpleAuthSession.extend({
|
|||
}),
|
||||
|
||||
authToken: computed('session.content.authenticated.user', function () {
|
||||
if (is.null(this.get('session.authenticator')) ||
|
||||
if (_.isNull(this.get('session.authenticator')) ||
|
||||
this.get('appMeta.secureMode')) return '';
|
||||
|
||||
if (this.get('session.authenticator') === 'authenticator:anonymous' ||
|
||||
|
@ -103,9 +101,6 @@ export default SimpleAuthSession.extend({
|
|||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.set('isMac', is.mac());
|
||||
this.set('isMobile', is.mobile());
|
||||
},
|
||||
|
||||
logout() {
|
||||
|
|
|
@ -34,7 +34,7 @@ export default Service.extend({
|
|||
return this.get('ajax').request(`templates/${folderId}`, {
|
||||
method: 'GET'
|
||||
}).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
let templates = ArrayProxy.create({
|
||||
content: A([])
|
||||
|
|
|
@ -56,7 +56,7 @@ export default Service.extend({
|
|||
// Returns all active users for organization.
|
||||
getAll() {
|
||||
return this.get('ajax').request(`users?active=1`).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
return response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
@ -71,10 +71,10 @@ export default Service.extend({
|
|||
getComplete(filter, limit) {
|
||||
filter = filter.trim();
|
||||
if (filter.length > 0) filter = encodeURIComponent(filter);
|
||||
if (is.null(limit) || is.undefined(limit)) limit = 100;
|
||||
if (_.isNull(limit) || _.isUndefined(limit)) limit = 100;
|
||||
|
||||
return this.get('ajax').request(`users?active=0&filter=${filter}&limit=${limit}`).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
return response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
@ -91,7 +91,7 @@ export default Service.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
@ -170,7 +170,7 @@ export default Service.extend({
|
|||
|
||||
// matchUsers on firstname, lastname, email
|
||||
matchUsers(text, limit) {
|
||||
if (is.null(limit) || is.undefined(limit)) limit = 100;
|
||||
if (_.isNull(limit) || _.isUndefined(limit)) limit = 100;
|
||||
|
||||
return this.get('ajax').request(`users/match?limit=${limit}`, {
|
||||
method: 'POST',
|
||||
|
@ -179,7 +179,7 @@ export default Service.extend({
|
|||
data: text
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
if (!_.isArray(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue