@vocollege/app 0.0.156 → 0.0.158
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/VoHelpers.d.ts +2 -2
- package/dist/modules/VoHelpers.js +13 -36
- package/package.json +1 -1
- package/src/modules/VoHelpers.ts +16 -32
|
@@ -34,7 +34,7 @@ export declare const wrapPromise: (promise: any) => {
|
|
|
34
34
|
};
|
|
35
35
|
export declare const downloadFile: (url: string) => void;
|
|
36
36
|
export declare const orderByPosition: (a: any, b: any) => 1 | -1 | 0;
|
|
37
|
-
export declare const orderByField: (a: any, b: any, field: string) => 1 | -1 | 0;
|
|
37
|
+
export declare const orderByField: (a: any, b: any, field: string, descending?: boolean) => 1 | -1 | 0;
|
|
38
38
|
export declare const shortenText: (str: string, limit?: number, stripHtml?: boolean, addEllipsis?: boolean) => string;
|
|
39
39
|
export declare const getImageContact: (item: any, width?: number, height?: number) => string;
|
|
40
40
|
export declare const getImage: (item: any, width: number, height: number, field?: string) => string;
|
|
@@ -42,7 +42,7 @@ export declare const getImageDescription: (item: any, field?: string) => any;
|
|
|
42
42
|
export declare const getContactName: (item?: GeneralObject) => string;
|
|
43
43
|
export declare const getUserString: (item?: GeneralObject) => string;
|
|
44
44
|
export declare const parseState: (state: any, initialState: any) => GeneralObject;
|
|
45
|
-
export declare const changeObj: (obj: any,
|
|
45
|
+
export declare const changeObj: (obj: any, key: string, value: any) => {};
|
|
46
46
|
export declare const reducer: (state: any, action: any) => any;
|
|
47
47
|
export declare const getGroupLogotype: (group: GeneralObject, logo?: string, output?: GeneralObject[]) => any;
|
|
48
48
|
export declare const getObjValue: (obj: any, ...props: string[]) => any;
|
|
@@ -238,12 +238,13 @@ var orderByPosition = function (a, b) {
|
|
|
238
238
|
return 0;
|
|
239
239
|
};
|
|
240
240
|
exports.orderByPosition = orderByPosition;
|
|
241
|
-
var orderByField = function (a, b, field) {
|
|
241
|
+
var orderByField = function (a, b, field, descending) {
|
|
242
|
+
if (descending === void 0) { descending = false; }
|
|
242
243
|
if (a[field] < b[field]) {
|
|
243
|
-
return -1;
|
|
244
|
+
return descending ? 1 : -1;
|
|
244
245
|
}
|
|
245
246
|
if (a[field] > b[field]) {
|
|
246
|
-
return 1;
|
|
247
|
+
return descending ? -1 : 1;
|
|
247
248
|
}
|
|
248
249
|
return 0;
|
|
249
250
|
};
|
|
@@ -325,27 +326,16 @@ var parseState = function (state, initialState) {
|
|
|
325
326
|
return newState;
|
|
326
327
|
};
|
|
327
328
|
exports.parseState = parseState;
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
//
|
|
336
|
-
var changeObj = function (obj, is, value) {
|
|
337
|
-
if (typeof is == "string")
|
|
338
|
-
return (0, exports.changeObj)(obj, is.split("."), value);
|
|
339
|
-
else if (is.length == 1 && value !== undefined)
|
|
340
|
-
return (obj[is[0]] = value);
|
|
341
|
-
else if (is.length == 0)
|
|
342
|
-
return obj;
|
|
343
|
-
else
|
|
344
|
-
return (0, exports.changeObj)(obj[is[0]], is.slice(1), value);
|
|
329
|
+
var changeObj = function (obj, key, value) {
|
|
330
|
+
var keys = key.split(".");
|
|
331
|
+
return keys.reduce(function (acc, v, i) {
|
|
332
|
+
if (i == keys.length - 1)
|
|
333
|
+
acc[v] = value;
|
|
334
|
+
return acc[v];
|
|
335
|
+
}, obj);
|
|
345
336
|
};
|
|
346
337
|
exports.changeObj = changeObj;
|
|
347
338
|
var reducer = function (state, action) {
|
|
348
|
-
var _a;
|
|
349
339
|
var key = action.key, values = action.values;
|
|
350
340
|
if (!key) {
|
|
351
341
|
return __assign(__assign({}, state), values);
|
|
@@ -361,11 +351,8 @@ var reducer = function (state, action) {
|
|
|
361
351
|
}
|
|
362
352
|
return __assign(__assign({}, state), { loading: newValues });
|
|
363
353
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
return __assign({}, state);
|
|
367
|
-
}
|
|
368
|
-
return __assign(__assign({}, state), (_a = {}, _a[key] = values, _a));
|
|
354
|
+
(0, exports.changeObj)(state, key, values);
|
|
355
|
+
return __assign({}, state);
|
|
369
356
|
};
|
|
370
357
|
exports.reducer = reducer;
|
|
371
358
|
var getGroupLogotype = function (group, logo, output) {
|
|
@@ -382,16 +369,6 @@ var getGroupLogotype = function (group, logo, output) {
|
|
|
382
369
|
return null;
|
|
383
370
|
};
|
|
384
371
|
exports.getGroupLogotype = getGroupLogotype;
|
|
385
|
-
// export const makeId = (length = 10) => {
|
|
386
|
-
// let result = "";
|
|
387
|
-
// let characters =
|
|
388
|
-
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
389
|
-
// let charactersLength = characters.length;
|
|
390
|
-
// for (var i = 0; i < length; i++) {
|
|
391
|
-
// result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
392
|
-
// }
|
|
393
|
-
// return result;
|
|
394
|
-
// };
|
|
395
372
|
var getObjValue = function (obj) {
|
|
396
373
|
var props = [];
|
|
397
374
|
for (var _i = 1; _i < arguments.length; _i++) {
|
package/package.json
CHANGED
package/src/modules/VoHelpers.ts
CHANGED
|
@@ -194,12 +194,17 @@ export const orderByPosition = (a: any, b: any) => {
|
|
|
194
194
|
return 0;
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
-
export const orderByField = (
|
|
197
|
+
export const orderByField = (
|
|
198
|
+
a: any,
|
|
199
|
+
b: any,
|
|
200
|
+
field: string,
|
|
201
|
+
descending = false
|
|
202
|
+
) => {
|
|
198
203
|
if (a[field] < b[field]) {
|
|
199
|
-
return -1;
|
|
204
|
+
return descending ? 1 : -1;
|
|
200
205
|
}
|
|
201
206
|
if (a[field] > b[field]) {
|
|
202
|
-
return 1;
|
|
207
|
+
return descending ? -1 : 1;
|
|
203
208
|
}
|
|
204
209
|
return 0;
|
|
205
210
|
};
|
|
@@ -283,19 +288,12 @@ export const parseState = (state: any, initialState: any) => {
|
|
|
283
288
|
return newState;
|
|
284
289
|
};
|
|
285
290
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
// data = value;
|
|
293
|
-
//
|
|
294
|
-
export const changeObj = (obj: any, is: any, value: any): {} => {
|
|
295
|
-
if (typeof is == "string") return changeObj(obj, is.split("."), value);
|
|
296
|
-
else if (is.length == 1 && value !== undefined) return (obj[is[0]] = value);
|
|
297
|
-
else if (is.length == 0) return obj;
|
|
298
|
-
else return changeObj(obj[is[0]], is.slice(1), value);
|
|
291
|
+
export const changeObj = (obj: any, key: string, value: any): {} => {
|
|
292
|
+
let keys = key.split(".");
|
|
293
|
+
return keys.reduce((acc, v, i) => {
|
|
294
|
+
if (i == keys.length - 1) acc[v] = value;
|
|
295
|
+
return acc[v];
|
|
296
|
+
}, obj);
|
|
299
297
|
};
|
|
300
298
|
|
|
301
299
|
export const reducer = (state: any, action: any) => {
|
|
@@ -313,11 +311,8 @@ export const reducer = (state: any, action: any) => {
|
|
|
313
311
|
}
|
|
314
312
|
return { ...state, loading: newValues };
|
|
315
313
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return { ...state };
|
|
319
|
-
}
|
|
320
|
-
return { ...state, [key]: values };
|
|
314
|
+
changeObj(state, key, values);
|
|
315
|
+
return { ...state };
|
|
321
316
|
};
|
|
322
317
|
|
|
323
318
|
export const getGroupLogotype = (
|
|
@@ -335,17 +330,6 @@ export const getGroupLogotype = (
|
|
|
335
330
|
return null;
|
|
336
331
|
};
|
|
337
332
|
|
|
338
|
-
// export const makeId = (length = 10) => {
|
|
339
|
-
// let result = "";
|
|
340
|
-
// let characters =
|
|
341
|
-
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
342
|
-
// let charactersLength = characters.length;
|
|
343
|
-
// for (var i = 0; i < length; i++) {
|
|
344
|
-
// result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
345
|
-
// }
|
|
346
|
-
// return result;
|
|
347
|
-
// };
|
|
348
|
-
|
|
349
333
|
export const getObjValue = (obj: any, ...props: string[]): any => {
|
|
350
334
|
return (
|
|
351
335
|
obj &&
|