@singularsystems/neo-core 1.2.3 → 1.3.1
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/AppServices/Config/ConfigService.d.ts +2 -0
- package/dist/AppServices/Config/ConfigService.js +9 -0
- package/dist/Components/BootstrapTypes.d.ts +16 -26
- package/dist/Data/Deserialiser.js +10 -5
- package/dist/Data/Serialiser.js +5 -2
- package/dist/Dates/DateUtils.d.ts +7 -2
- package/dist/Dates/DateUtils.js +13 -2
- package/dist/Misc.d.ts +1 -1
- package/dist/Misc.js +1 -1
- package/dist/Model/IModelBase.d.ts +2 -0
- package/dist/Model/List.d.ts +23 -2
- package/dist/Model/List.js +52 -5
- package/dist/Model/Misc.d.ts +6 -0
- package/dist/Model/Misc.js +7 -0
- package/dist/Model/ModelBase.d.ts +2 -1
- package/dist/Model/ModelBase.js +7 -2
- package/dist/Model/PropertyInfo.js +4 -1
- package/dist/Settings.d.ts +10 -2
- package/dist/Settings.js +15 -3
- package/dist/Utils.js +5 -0
- package/package.json +4 -4
|
@@ -23,4 +23,6 @@ export declare class ConfigService implements IConfigService {
|
|
|
23
23
|
fetchConfig(path?: string | undefined): AxiosPromise<any>;
|
|
24
24
|
setConfig(configData: any): IConfigModel;
|
|
25
25
|
static get isDevelopment(): boolean;
|
|
26
|
+
/** Throws the error if in development mode, otherwise logs it. */
|
|
27
|
+
static tryShowError(e: any): void;
|
|
26
28
|
}
|
|
@@ -61,6 +61,15 @@ var ConfigService = /** @class */ (function () {
|
|
|
61
61
|
enumerable: false,
|
|
62
62
|
configurable: true
|
|
63
63
|
});
|
|
64
|
+
/** Throws the error if in development mode, otherwise logs it. */
|
|
65
|
+
ConfigService.tryShowError = function (e) {
|
|
66
|
+
if (this.isDevelopment) {
|
|
67
|
+
throw e;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.error(e);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
64
73
|
ConfigService = __decorate([
|
|
65
74
|
injectable(),
|
|
66
75
|
__param(0, inject(NeoTypes.Config.ConfigModel.symbol)),
|
|
@@ -7,31 +7,21 @@ export type flexJustifyContent = "start" | "end" | "center" | "between";
|
|
|
7
7
|
export type breakpoint = "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
|
|
8
8
|
export type ElementOrText = any;
|
|
9
9
|
export type BorderType = "standard" | "borderless" | "bordered";
|
|
10
|
-
export interface
|
|
11
|
-
/**
|
|
12
|
-
xs
|
|
13
|
-
/**
|
|
14
|
-
sm
|
|
15
|
-
/**
|
|
16
|
-
md
|
|
17
|
-
/**
|
|
18
|
-
lg
|
|
19
|
-
/**
|
|
20
|
-
xl
|
|
21
|
-
/**
|
|
22
|
-
xxl
|
|
10
|
+
export interface IBootstrapSizes<T> {
|
|
11
|
+
/** Extra small or bigger */
|
|
12
|
+
xs: T;
|
|
13
|
+
/** Small or bigger */
|
|
14
|
+
sm: T;
|
|
15
|
+
/** Medium or bigger */
|
|
16
|
+
md: T;
|
|
17
|
+
/** Large or bigger */
|
|
18
|
+
lg: T;
|
|
19
|
+
/** Extra large or bigger */
|
|
20
|
+
xl: T;
|
|
21
|
+
/** Largest size */
|
|
22
|
+
xxl: T;
|
|
23
23
|
}
|
|
24
|
-
export interface
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/** Number of columns to fit in a row when the screen is small or bigger */
|
|
28
|
-
sm?: columnCount;
|
|
29
|
-
/** Number of columns to fit in a row when the screen is medium or bigger */
|
|
30
|
-
md?: columnCount;
|
|
31
|
-
/** Number of columns to fit in a row when the screen is large or bigger */
|
|
32
|
-
lg?: columnCount;
|
|
33
|
-
/** Number of columns to fit in a row when the screen is extra lage or bigger */
|
|
34
|
-
xl?: columnCount;
|
|
35
|
-
/** Number of columns to fit in a row when the screen is the largest size */
|
|
36
|
-
xxl?: columnCount;
|
|
24
|
+
export interface IColumnWidthBreakpoints extends Partial<IBootstrapSizes<columnWidth>> {
|
|
25
|
+
}
|
|
26
|
+
export interface IColumnCountBreakpoints extends Partial<IBootstrapSizes<columnCount>> {
|
|
37
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TrackingState, SerialiseType, DataType, RelationType } from '../Model/Misc';
|
|
1
|
+
import { TrackingState, SerialiseType, DataType, RelationType, RemoveItemBehavior } from '../Model/Misc';
|
|
2
2
|
import { Utils } from '../Utils';
|
|
3
3
|
import NumberUtils from "../NumberUtils";
|
|
4
4
|
var Deserialiser = /** @class */ (function () {
|
|
@@ -73,9 +73,14 @@ var Deserialiser = /** @class */ (function () {
|
|
|
73
73
|
}
|
|
74
74
|
//create an index of the to objects
|
|
75
75
|
var toIndex = {};
|
|
76
|
+
var list = to;
|
|
76
77
|
var deletedItems = [];
|
|
77
|
-
for (var i =
|
|
78
|
-
|
|
78
|
+
for (var i = to.length - 1; i >= 0; i--) {
|
|
79
|
+
var item = to[i];
|
|
80
|
+
toIndex[item.entityIdentifier] = to[i];
|
|
81
|
+
if (item.isSelfDeleting) {
|
|
82
|
+
to.splice(i, 1);
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
if (this.options.removeOldItems) {
|
|
81
86
|
to.length = 0;
|
|
@@ -115,7 +120,7 @@ var Deserialiser = /** @class */ (function () {
|
|
|
115
120
|
if (deserialise)
|
|
116
121
|
this.deserialiseObject(fromItem, toItem, addToList);
|
|
117
122
|
if (addToList || this.options.removeOldItems) {
|
|
118
|
-
if (fromItem.trackingState === TrackingState.Deleted) {
|
|
123
|
+
if (fromItem.trackingState === TrackingState.Deleted && list.removeItemBehavior === RemoveItemBehavior.Remove) {
|
|
119
124
|
deletedItems.push(toItem);
|
|
120
125
|
}
|
|
121
126
|
else {
|
|
@@ -126,7 +131,6 @@ var Deserialiser = /** @class */ (function () {
|
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
133
|
}
|
|
129
|
-
var list = to;
|
|
130
134
|
if (list.deletedList) {
|
|
131
135
|
list.clearDeletedList();
|
|
132
136
|
}
|
|
@@ -248,6 +252,7 @@ var Deserialiser = /** @class */ (function () {
|
|
|
248
252
|
}
|
|
249
253
|
else if (from.trackingState === TrackingState.Deleted) {
|
|
250
254
|
toModel.isNew = false;
|
|
255
|
+
toModel.isSelfDeleting = true;
|
|
251
256
|
}
|
|
252
257
|
else {
|
|
253
258
|
toModel.isSelfDirty = true;
|
package/dist/Data/Serialiser.js
CHANGED
|
@@ -90,7 +90,10 @@ var Serialiser = /** @class */ (function () {
|
|
|
90
90
|
}
|
|
91
91
|
//Set tracking state
|
|
92
92
|
if (!this.options.suppressTrackingState && !isDictionary) {
|
|
93
|
-
if (from.
|
|
93
|
+
if (from.isSelfDeleting) {
|
|
94
|
+
to.trackingState = TrackingState.Deleted;
|
|
95
|
+
}
|
|
96
|
+
else if (from.isNew) {
|
|
94
97
|
to.trackingState = TrackingState.Added;
|
|
95
98
|
}
|
|
96
99
|
else if (from.isSelfDirty) {
|
|
@@ -149,7 +152,7 @@ var Serialiser = /** @class */ (function () {
|
|
|
149
152
|
to[key] = NumberUtils.decimalService.toNumber(fromValue);
|
|
150
153
|
}
|
|
151
154
|
else if (propertyInfo.timeZoneSerialisation === TimeZoneFormat.None && fromValue instanceof Date) {
|
|
152
|
-
to[key] = DateUtils.
|
|
155
|
+
to[key] = DateUtils.formatApi(fromValue, propertyInfo.timeZoneSerialisation);
|
|
153
156
|
}
|
|
154
157
|
else {
|
|
155
158
|
to[key] = fromValue;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPropertyInstance } from "../Model/PropertyInstance";
|
|
2
|
+
import { TimeZoneFormat } from "../Misc";
|
|
2
3
|
import { ITimeSpan, TimeSpan } from "./TimeSpan";
|
|
3
4
|
export default class DateUtils {
|
|
4
5
|
static defaultFormatString: string;
|
|
@@ -11,7 +12,11 @@ export default class DateUtils {
|
|
|
11
12
|
monthNames: string[];
|
|
12
13
|
};
|
|
13
14
|
static format(date: Date, formatString?: string, utc?: boolean): string;
|
|
14
|
-
static format(dateProperty:
|
|
15
|
+
static format(dateProperty: IPropertyInstance<Date>): string;
|
|
16
|
+
/**
|
|
17
|
+
* Formats a date using api standards.
|
|
18
|
+
*/
|
|
19
|
+
static formatApi(date: Date, timezoneFormat: TimeZoneFormat): string;
|
|
15
20
|
private static pad;
|
|
16
21
|
/**
|
|
17
22
|
* Tries to parse a date from a string using the supplied format string
|
package/dist/Dates/DateUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TimeZoneFormat } from "../Misc";
|
|
2
2
|
import { TimeSpan } from "./TimeSpan";
|
|
3
3
|
var DateUtils = /** @class */ (function () {
|
|
4
4
|
function DateUtils() {
|
|
@@ -9,7 +9,7 @@ var DateUtils = /** @class */ (function () {
|
|
|
9
9
|
var dateProperty = dateOrDateProperty;
|
|
10
10
|
if (dateProperty === null || dateProperty === void 0 ? void 0 : dateProperty.propertyInfo) {
|
|
11
11
|
date = dateProperty.value;
|
|
12
|
-
formatString = dateProperty.propertyInfo.timeZoneSerialisation ===
|
|
12
|
+
formatString = dateProperty.propertyInfo.timeZoneSerialisation === TimeZoneFormat.None ? DateUtils.defaultFormatString : DateUtils.defaultFormatStringWithTime;
|
|
13
13
|
}
|
|
14
14
|
if (!date)
|
|
15
15
|
return "";
|
|
@@ -57,6 +57,17 @@ var DateUtils = /** @class */ (function () {
|
|
|
57
57
|
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Formats a date using api standards.
|
|
62
|
+
*/
|
|
63
|
+
DateUtils.formatApi = function (date, timezoneFormat) {
|
|
64
|
+
if (timezoneFormat === TimeZoneFormat.UTC) {
|
|
65
|
+
return date.toISOString();
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return DateUtils.format(date, "yyyy-MM-dd") + "T00:00:00";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
60
71
|
DateUtils.pad = function (val, len) {
|
|
61
72
|
if (len === void 0) { len = 2; }
|
|
62
73
|
val = String(val);
|
package/dist/Misc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DataType, RelationType, SerialiseType, TrackingState, IDisposable, IAutoRunner, IAutoRunnerOptions, TimeZoneFormat } from './Model/Misc';
|
|
1
|
+
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, IDisposable, IAutoRunner, IAutoRunnerOptions, TimeZoneFormat } from './Model/Misc';
|
|
2
2
|
export { default as Globals } from './Globals';
|
|
3
3
|
export { NumberFormat } from './NumberUtils';
|
|
4
4
|
export { Settings } from './Settings';
|
package/dist/Misc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { DataType, RelationType, SerialiseType, TrackingState, TimeZoneFormat } from './Model/Misc';
|
|
1
|
+
export { DataType, RelationType, SerialiseType, TrackingState, RemoveItemBehavior, TimeZoneFormat } from './Model/Misc';
|
|
2
2
|
export { default as Globals } from './Globals';
|
|
3
3
|
export { NumberFormat } from './NumberUtils';
|
|
4
4
|
export { Settings } from './Settings';
|
|
@@ -95,6 +95,8 @@ export interface IModelBaseInternal {
|
|
|
95
95
|
export interface IModelBase extends INonObservableModelBase {
|
|
96
96
|
entityIdentifier: string;
|
|
97
97
|
isSelfDirty: boolean;
|
|
98
|
+
/** Indicates that this object has been marked for deletion. */
|
|
99
|
+
isSelfDeleting: boolean;
|
|
98
100
|
isNew: boolean;
|
|
99
101
|
readonly isSelfValid: boolean;
|
|
100
102
|
readonly isValid: boolean;
|
package/dist/Model/List.d.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
1
|
import { ISerialiseOptions } from '../Data/Serialiser';
|
|
2
2
|
import { PlainObject, PartialPlainObject, PlainTrackedObject, IMetaItem, ObjectFactory, IObjectFactoryOptions } from './IModelBase';
|
|
3
3
|
import { IDeserialiseOptions } from '../Data/Deserialiser';
|
|
4
|
+
import { RemoveItemBehavior } from "./Misc";
|
|
5
|
+
interface IListCreationOptions {
|
|
6
|
+
itemFactory?: ObjectFactory;
|
|
7
|
+
onBeginRemove?: RemoveItemBehavior;
|
|
8
|
+
}
|
|
4
9
|
export default class List<T> extends Array<T> {
|
|
5
10
|
attachedTo: object | null;
|
|
6
11
|
childObjectType?: new () => T;
|
|
7
12
|
itemFactory?: ObjectFactory;
|
|
13
|
+
removeItemBehavior?: RemoveItemBehavior;
|
|
8
14
|
private _deletedList;
|
|
9
15
|
get deletedList(): T[];
|
|
10
16
|
get canDeserialise(): ObjectFactory | (new () => T) | undefined;
|
|
17
|
+
/** Returns items that are not marked for deletion */
|
|
18
|
+
get activeItems(): T[];
|
|
19
|
+
/** Returns the count of non deleted items. */
|
|
20
|
+
get activeLength(): number;
|
|
11
21
|
private baseMethods;
|
|
12
22
|
/**
|
|
13
23
|
* Creates an instance of a list. A List is an array with the ability to auto create child instances, and track removed items.
|
|
14
24
|
* @param childObjectType Usually the type that the list contains. Can also pass in options for advanced usage.
|
|
15
25
|
*/
|
|
16
|
-
constructor(childObjectType?: (new () => T) | IObjectFactoryOptions);
|
|
26
|
+
constructor(childObjectType?: (new () => T) | IObjectFactoryOptions, options?: IListCreationOptions);
|
|
17
27
|
/**
|
|
18
28
|
* Copies the methods and properties from the prototype to the new instance.
|
|
19
29
|
* This is needed because vue / mobx changes the prototype to its own.
|
|
@@ -55,7 +65,7 @@ export default class List<T> extends Array<T> {
|
|
|
55
65
|
/**
|
|
56
66
|
* Converts a plain javascript array into a neo model graph.
|
|
57
67
|
*/
|
|
58
|
-
static fromJSArray<T>(childType: new () => T, jsArray: PartialPlainObject<T>[],
|
|
68
|
+
static fromJSArray<T>(childType: new () => T, jsArray: PartialPlainObject<T>[], deserialiseOptions?: IDeserialiseOptions, listOptions?: IListCreationOptions): List<T>;
|
|
59
69
|
/** Creates a new item of type T */
|
|
60
70
|
createChild(): T;
|
|
61
71
|
push(...items: T[]): any;
|
|
@@ -63,6 +73,16 @@ export default class List<T> extends Array<T> {
|
|
|
63
73
|
private setParent;
|
|
64
74
|
/** Creates a new item of type T, adds it to the array and returns the new item. */
|
|
65
75
|
addNew(): T;
|
|
76
|
+
/**
|
|
77
|
+
* If `removeItemBehavior` is `MarkDeleted`, will toggle the value of `isSelfDeleting`.
|
|
78
|
+
* If `removeItemBehavior` is `Remove`, will remove the item from the array and add it to the deleted list.
|
|
79
|
+
*/
|
|
80
|
+
toggleRemove(item: T): void;
|
|
81
|
+
/**
|
|
82
|
+
* If `removeItemBehavior` is `MarkDeleted`, will set `isSelfDeleting` to true.
|
|
83
|
+
* If `removeItemBehavior` is `Remove`, will remove the item from the array and add it to the deleted list.
|
|
84
|
+
*/
|
|
85
|
+
beginRemove(item: T): void;
|
|
66
86
|
/**
|
|
67
87
|
* Removes an item from the array, and adds it to the deleted list. Deleted items will be included when calling toJSArray
|
|
68
88
|
* @param item Item to remove
|
|
@@ -83,3 +103,4 @@ export default class List<T> extends Array<T> {
|
|
|
83
103
|
/** Indicates that the model is dirty and valid and can be saved. */
|
|
84
104
|
get readyToSave(): boolean;
|
|
85
105
|
}
|
|
106
|
+
export {};
|
package/dist/Model/List.js
CHANGED
|
@@ -3,21 +3,26 @@ import { JSFormatter } from '../Data/Serialiser';
|
|
|
3
3
|
import { Utils } from '../Utils';
|
|
4
4
|
import { ObservableValue } from './ObservableValue';
|
|
5
5
|
import { NeoTypeInfo } from './NeoTypeInfo';
|
|
6
|
+
import { RemoveItemBehavior } from "./Misc";
|
|
7
|
+
import { Settings } from "../Settings";
|
|
6
8
|
var List = /** @class */ (function (_super) {
|
|
7
9
|
__extends(List, _super);
|
|
8
10
|
/**
|
|
9
11
|
* Creates an instance of a list. A List is an array with the ability to auto create child instances, and track removed items.
|
|
10
12
|
* @param childObjectType Usually the type that the list contains. Can also pass in options for advanced usage.
|
|
11
13
|
*/
|
|
12
|
-
function List(childObjectType) {
|
|
14
|
+
function List(childObjectType, options) {
|
|
15
|
+
var _a;
|
|
13
16
|
var _this = _super.call(this) || this;
|
|
14
17
|
_this._deletedList = new ObservableValue([]);
|
|
15
18
|
if (typeof childObjectType === "function") {
|
|
16
19
|
_this.childObjectType = childObjectType;
|
|
20
|
+
_this.itemFactory = options === null || options === void 0 ? void 0 : options.itemFactory;
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
23
|
_this.itemFactory = childObjectType === null || childObjectType === void 0 ? void 0 : childObjectType.itemFactory;
|
|
20
24
|
}
|
|
25
|
+
_this.removeItemBehavior = (_a = options === null || options === void 0 ? void 0 : options.onBeginRemove) !== null && _a !== void 0 ? _a : Settings.list.removeItemBehavior;
|
|
21
26
|
List.copyMethods(_this);
|
|
22
27
|
return _this;
|
|
23
28
|
}
|
|
@@ -35,6 +40,22 @@ var List = /** @class */ (function (_super) {
|
|
|
35
40
|
enumerable: false,
|
|
36
41
|
configurable: true
|
|
37
42
|
});
|
|
43
|
+
Object.defineProperty(List.prototype, "activeItems", {
|
|
44
|
+
/** Returns items that are not marked for deletion */
|
|
45
|
+
get: function () {
|
|
46
|
+
return this.filter(function (item) { return !item.isSelfDeleting; });
|
|
47
|
+
},
|
|
48
|
+
enumerable: false,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
Object.defineProperty(List.prototype, "activeLength", {
|
|
52
|
+
/** Returns the count of non deleted items. */
|
|
53
|
+
get: function () {
|
|
54
|
+
return this.sum(function (item) { return item.isSelfDeleting ? 0 : 1; });
|
|
55
|
+
},
|
|
56
|
+
enumerable: false,
|
|
57
|
+
configurable: true
|
|
58
|
+
});
|
|
38
59
|
/**
|
|
39
60
|
* Copies the methods and properties from the prototype to the new instance.
|
|
40
61
|
* This is needed because vue / mobx changes the prototype to its own.
|
|
@@ -62,6 +83,7 @@ var List = /** @class */ (function (_super) {
|
|
|
62
83
|
List.prototype.setupProxy = function (proxy, attachedTo) {
|
|
63
84
|
proxy.childObjectType = this.childObjectType;
|
|
64
85
|
proxy.itemFactory = this.itemFactory;
|
|
86
|
+
proxy.removeItemBehavior = this.removeItemBehavior;
|
|
65
87
|
proxy._deletedList = new ObservableValue([]);
|
|
66
88
|
proxy.attachedTo = attachedTo;
|
|
67
89
|
};
|
|
@@ -90,9 +112,9 @@ var List = /** @class */ (function (_super) {
|
|
|
90
112
|
/**
|
|
91
113
|
* Converts a plain javascript array into a neo model graph.
|
|
92
114
|
*/
|
|
93
|
-
List.fromJSArray = function (childType, jsArray,
|
|
94
|
-
var list = new List(childType);
|
|
95
|
-
list.set(jsArray,
|
|
115
|
+
List.fromJSArray = function (childType, jsArray, deserialiseOptions, listOptions) {
|
|
116
|
+
var list = new List(childType, listOptions);
|
|
117
|
+
list.set(jsArray, deserialiseOptions);
|
|
96
118
|
return list;
|
|
97
119
|
};
|
|
98
120
|
/** Creates a new item of type T */
|
|
@@ -153,6 +175,30 @@ var List = /** @class */ (function (_super) {
|
|
|
153
175
|
this.push(newItem);
|
|
154
176
|
return newItem;
|
|
155
177
|
};
|
|
178
|
+
/**
|
|
179
|
+
* If `removeItemBehavior` is `MarkDeleted`, will toggle the value of `isSelfDeleting`.
|
|
180
|
+
* If `removeItemBehavior` is `Remove`, will remove the item from the array and add it to the deleted list.
|
|
181
|
+
*/
|
|
182
|
+
List.prototype.toggleRemove = function (item) {
|
|
183
|
+
if (item.isSelfDeleting) {
|
|
184
|
+
item.isSelfDeleting = false;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
this.beginRemove(item);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* If `removeItemBehavior` is `MarkDeleted`, will set `isSelfDeleting` to true.
|
|
192
|
+
* If `removeItemBehavior` is `Remove`, will remove the item from the array and add it to the deleted list.
|
|
193
|
+
*/
|
|
194
|
+
List.prototype.beginRemove = function (item) {
|
|
195
|
+
if (!item.isNew && this.removeItemBehavior === RemoveItemBehavior.MarkDeleted) {
|
|
196
|
+
item.isSelfDeleting = true;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
this.remove(item);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
156
202
|
/**
|
|
157
203
|
* Removes an item from the array, and adds it to the deleted list. Deleted items will be included when calling toJSArray
|
|
158
204
|
* @param item Item to remove
|
|
@@ -194,7 +240,8 @@ var List = /** @class */ (function (_super) {
|
|
|
194
240
|
/** True if all items in the list are valid. */
|
|
195
241
|
get: function () {
|
|
196
242
|
for (var i = 0; i < this.length; i++) {
|
|
197
|
-
|
|
243
|
+
var item = this[i];
|
|
244
|
+
if (!item.isValid) {
|
|
198
245
|
return false;
|
|
199
246
|
}
|
|
200
247
|
}
|
package/dist/Model/Misc.d.ts
CHANGED
|
@@ -50,6 +50,12 @@ export declare enum TrackingState {
|
|
|
50
50
|
Modified = 2,
|
|
51
51
|
Deleted = 3
|
|
52
52
|
}
|
|
53
|
+
export declare enum RemoveItemBehavior {
|
|
54
|
+
/** Removes the item from the active items, and adds it to the deleted list. */
|
|
55
|
+
Remove = 1,
|
|
56
|
+
/** Leaves the item in the active list, and marks it as deleted. */
|
|
57
|
+
MarkDeleted = 2
|
|
58
|
+
}
|
|
53
59
|
export interface IDisposable {
|
|
54
60
|
dispose(): void;
|
|
55
61
|
}
|
package/dist/Model/Misc.js
CHANGED
|
@@ -57,3 +57,10 @@ export var TrackingState;
|
|
|
57
57
|
TrackingState[TrackingState["Modified"] = 2] = "Modified";
|
|
58
58
|
TrackingState[TrackingState["Deleted"] = 3] = "Deleted";
|
|
59
59
|
})(TrackingState || (TrackingState = {}));
|
|
60
|
+
export var RemoveItemBehavior;
|
|
61
|
+
(function (RemoveItemBehavior) {
|
|
62
|
+
/** Removes the item from the active items, and adds it to the deleted list. */
|
|
63
|
+
RemoveItemBehavior[RemoveItemBehavior["Remove"] = 1] = "Remove";
|
|
64
|
+
/** Leaves the item in the active list, and marks it as deleted. */
|
|
65
|
+
RemoveItemBehavior[RemoveItemBehavior["MarkDeleted"] = 2] = "MarkDeleted";
|
|
66
|
+
})(RemoveItemBehavior || (RemoveItemBehavior = {}));
|
|
@@ -9,8 +9,9 @@ export default abstract class ModelBase extends BindableBase implements IModelBa
|
|
|
9
9
|
validator: IModelValidator;
|
|
10
10
|
isNew: boolean;
|
|
11
11
|
isSelfDirty: boolean;
|
|
12
|
+
isSelfDeleting: boolean;
|
|
12
13
|
/**
|
|
13
|
-
* Returns true if the object itself is dirty, or
|
|
14
|
+
* Returns true if the object itself is dirty, or is being deleted. Then performs the same check recursively on all child objects and lists.
|
|
14
15
|
* IsNew does not affect the value of IsDirty.
|
|
15
16
|
*/
|
|
16
17
|
get isDirty(): boolean;
|
package/dist/Model/ModelBase.js
CHANGED
|
@@ -17,16 +17,17 @@ var ModelBase = /** @class */ (function (_super) {
|
|
|
17
17
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
18
18
|
_this.isNew = true;
|
|
19
19
|
_this.isSelfDirty = true;
|
|
20
|
+
_this.isSelfDeleting = false;
|
|
20
21
|
return _this;
|
|
21
22
|
}
|
|
22
23
|
Object.defineProperty(ModelBase.prototype, "isDirty", {
|
|
23
24
|
/**
|
|
24
|
-
* Returns true if the object itself is dirty, or
|
|
25
|
+
* Returns true if the object itself is dirty, or is being deleted. Then performs the same check recursively on all child objects and lists.
|
|
25
26
|
* IsNew does not affect the value of IsDirty.
|
|
26
27
|
*/
|
|
27
28
|
get: function () {
|
|
28
29
|
return ModelTraverser.traverseItems(this, new ModelTraverser.BooleanRecursionState(false), function (item, state) {
|
|
29
|
-
if (item.isSelfDirty) {
|
|
30
|
+
if (item.isSelfDirty || item.isSelfDeleting) {
|
|
30
31
|
state.flag = true;
|
|
31
32
|
state.stop = true;
|
|
32
33
|
}
|
|
@@ -173,6 +174,10 @@ var ModelBase = /** @class */ (function (_super) {
|
|
|
173
174
|
NoTracking(),
|
|
174
175
|
__metadata("design:type", Object)
|
|
175
176
|
], ModelBase.prototype, "isSelfDirty", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
NoTracking(),
|
|
179
|
+
__metadata("design:type", Object)
|
|
180
|
+
], ModelBase.prototype, "isSelfDeleting", void 0);
|
|
176
181
|
__decorate([
|
|
177
182
|
Computed(false),
|
|
178
183
|
__metadata("design:type", Object),
|
|
@@ -75,8 +75,11 @@ var PropertyInfo = /** @class */ (function () {
|
|
|
75
75
|
return clone;
|
|
76
76
|
};
|
|
77
77
|
PropertyInfo.prototype.setPropertyType = function (propertyType) {
|
|
78
|
+
var _a;
|
|
78
79
|
if (typeof propertyType === "function") {
|
|
79
|
-
|
|
80
|
+
var constructor = (_a = propertyType.prototype) === null || _a === void 0 ? void 0 : _a.constructor;
|
|
81
|
+
// Anonymous functions have a constructor name of "" or undefined.
|
|
82
|
+
if ((constructor === null || constructor === void 0 ? void 0 : constructor.neo) === undefined && (!propertyType.prototype || !(constructor === null || constructor === void 0 ? void 0 : constructor.name))) {
|
|
80
83
|
this.typeCallback = propertyType;
|
|
81
84
|
}
|
|
82
85
|
else {
|
package/dist/Settings.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ValidationDisplayMode } from './Validation/Misc';
|
|
2
2
|
import { IButtonOptions } from './Components/ButtonOptions';
|
|
3
3
|
import { BorderType } from "./Components/BootstrapTypes";
|
|
4
|
-
import { DataType } from './Model/Misc';
|
|
4
|
+
import { DataType, RemoveItemBehavior } from './Model/Misc';
|
|
5
5
|
export declare const Settings: {
|
|
6
6
|
bootstrap: {
|
|
7
7
|
version: number;
|
|
@@ -16,6 +16,10 @@ export declare const Settings: {
|
|
|
16
16
|
validationDisplayMode: ValidationDisplayMode;
|
|
17
17
|
validationModalCloseButton: Partial<IButtonOptions> | false | undefined;
|
|
18
18
|
};
|
|
19
|
+
list: {
|
|
20
|
+
/** Indicates how removing an item from a list should be handled. */
|
|
21
|
+
removeItemBehavior: RemoveItemBehavior;
|
|
22
|
+
};
|
|
19
23
|
icons: {
|
|
20
24
|
loadingIcon: any;
|
|
21
25
|
errorIcon: any;
|
|
@@ -25,8 +29,9 @@ export declare const Settings: {
|
|
|
25
29
|
collapsed: any;
|
|
26
30
|
sortAsc: any;
|
|
27
31
|
sortDesc: any;
|
|
28
|
-
/**
|
|
32
|
+
/** **Note:** also change the back icon in the `buttons.backButton` setting. */
|
|
29
33
|
backIcon: any;
|
|
34
|
+
unDelete: any;
|
|
30
35
|
shouldSuppress: (context: {
|
|
31
36
|
icon: any;
|
|
32
37
|
component: "button" | "card" | "tab";
|
|
@@ -70,6 +75,8 @@ export declare const Settings: {
|
|
|
70
75
|
* Default styles to apply to buttons added to a button column.
|
|
71
76
|
*/
|
|
72
77
|
buttonColumnButtons: IButtonOptions;
|
|
78
|
+
/** Allows overriding the tooltip shown when an item is marked for deletion. */
|
|
79
|
+
isDeletingTooltip: string;
|
|
73
80
|
};
|
|
74
81
|
modal: {
|
|
75
82
|
/** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
|
|
@@ -116,5 +123,6 @@ export declare const Settings: {
|
|
|
116
123
|
buttons: {
|
|
117
124
|
/** @deprecated Use `settings.icons.shouldSuppress` instead. */
|
|
118
125
|
suppressIcons: boolean;
|
|
126
|
+
backButton: IButtonOptions;
|
|
119
127
|
};
|
|
120
128
|
};
|
package/dist/Settings.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationDisplayMode } from './Validation/Misc';
|
|
2
|
-
import { DataType } from './Model/Misc';
|
|
2
|
+
import { DataType, RemoveItemBehavior } from './Model/Misc';
|
|
3
3
|
export var Settings = {
|
|
4
4
|
bootstrap: {
|
|
5
5
|
version: 4,
|
|
@@ -14,6 +14,10 @@ export var Settings = {
|
|
|
14
14
|
validationDisplayMode: ValidationDisplayMode.AfterBlur,
|
|
15
15
|
validationModalCloseButton: undefined,
|
|
16
16
|
},
|
|
17
|
+
list: {
|
|
18
|
+
/** Indicates how removing an item from a list should be handled. */
|
|
19
|
+
removeItemBehavior: RemoveItemBehavior.Remove,
|
|
20
|
+
},
|
|
17
21
|
icons: {
|
|
18
22
|
loadingIcon: "fa-circle-notch",
|
|
19
23
|
errorIcon: "fa-exclamation-triangle",
|
|
@@ -23,8 +27,9 @@ export var Settings = {
|
|
|
23
27
|
collapsed: "far-plus-square",
|
|
24
28
|
sortAsc: "sort-up",
|
|
25
29
|
sortDesc: "sort-down",
|
|
26
|
-
/**
|
|
30
|
+
/** **Note:** also change the back icon in the `buttons.backButton` setting. */
|
|
27
31
|
backIcon: "arrow-left",
|
|
32
|
+
unDelete: "trash-restore",
|
|
28
33
|
shouldSuppress: function (context) { return false; },
|
|
29
34
|
},
|
|
30
35
|
/** Grid default settings */
|
|
@@ -87,7 +92,9 @@ export var Settings = {
|
|
|
87
92
|
/**
|
|
88
93
|
* Default styles to apply to buttons added to a button column.
|
|
89
94
|
*/
|
|
90
|
-
buttonColumnButtons: {}
|
|
95
|
+
buttonColumnButtons: {},
|
|
96
|
+
/** Allows overriding the tooltip shown when an item is marked for deletion. */
|
|
97
|
+
isDeletingTooltip: "Item is marked for deletion, please click save.",
|
|
91
98
|
},
|
|
92
99
|
modal: {
|
|
93
100
|
/** Set to true if ModalUtils.showMessage() should show an accept button instead of close button. */
|
|
@@ -143,5 +150,10 @@ export var Settings = {
|
|
|
143
150
|
buttons: {
|
|
144
151
|
/** @deprecated Use `settings.icons.shouldSuppress` instead. */
|
|
145
152
|
suppressIcons: false,
|
|
153
|
+
backButton: {
|
|
154
|
+
isOutline: true,
|
|
155
|
+
icon: "arrow-left",
|
|
156
|
+
text: "Back",
|
|
157
|
+
},
|
|
146
158
|
}
|
|
147
159
|
};
|
package/dist/Utils.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __spreadArray } from "tslib";
|
|
2
2
|
import { DebounceHelper } from './DebounceHelper';
|
|
3
3
|
import { ensureTypeInfo } from './Model/NeoTypeInfo';
|
|
4
|
+
import DateUtils from "./Dates/DateUtils";
|
|
5
|
+
import { TimeZoneFormat } from "./Misc";
|
|
4
6
|
var lut = [];
|
|
5
7
|
for (var i = 0; i < 256; i++) {
|
|
6
8
|
lut[i] = (i < 16 ? '0' : '') + (i).toString(16);
|
|
@@ -233,6 +235,9 @@ var Utils = /** @class */ (function () {
|
|
|
233
235
|
}
|
|
234
236
|
return queryString;
|
|
235
237
|
}
|
|
238
|
+
if (plainObject instanceof Date) {
|
|
239
|
+
return DateUtils.formatApi(plainObject, DateUtils.stripTime(plainObject).getTime() === plainObject.getTime() ? TimeZoneFormat.None : TimeZoneFormat.UTC);
|
|
240
|
+
}
|
|
236
241
|
return buildQueryString.apply(void 0, __spreadArray([plainObject, ""], properties, false));
|
|
237
242
|
};
|
|
238
243
|
return Utils;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@singularsystems/neo-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Core functionality for the Neo client library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/jest": "29.5.14",
|
|
19
|
-
"@types/node": "22.
|
|
19
|
+
"@types/node": "22.15.30",
|
|
20
20
|
"decimal.js-light": "2.5.1",
|
|
21
21
|
"jest": "29.7.0",
|
|
22
|
-
"ts-jest": "29.
|
|
22
|
+
"ts-jest": "29.3.4",
|
|
23
23
|
"typescript": "5.7.3"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"axios": ">=1.4.0",
|
|
34
34
|
"inversify": ">=5.0.1"
|
|
35
35
|
},
|
|
36
|
-
"packageManager": "yarn@4.
|
|
36
|
+
"packageManager": "yarn@4.9.2"
|
|
37
37
|
}
|