@zohodesk/library-platform 1.1.3-exp.3 → 1.1.3-exp.4
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/es/bc/zhttp/Errors.js +14 -0
- package/es/bc/zhttp/index.js +3 -1
- package/es/bc/zlist/Constants.js +8 -1
- package/es/bc/zlist/Events.js +140 -0
- package/es/bc/zlist/index.js +2 -1
- package/es/bc/zrecord/Constants.js +3 -1
- package/es/cc/component/FallbackView.js +1 -0
- package/es/cc/fields/currency/Model.js +2 -0
- package/es/cc/fields/field/Properties.js +1 -1
- package/es/cc/fields/formula/Model.js +5 -0
- package/es/cc/index.js +1 -0
- package/es/cc/link/Properties.js +0 -1
- package/es/cc/table-connected/ErrorEventType.js +32 -0
- package/es/cc/table-connected/Events.js +96 -0
- package/es/cc/table-connected/Properties.js +16 -0
- package/es/cc/table-connected/SdkContract.js +120 -0
- package/es/cc/table-connected/constants/Events.js +2 -0
- package/es/cc/table-connected/index.js +3 -1
- package/es/cc/table-list/Constants.js +4 -0
- package/es/cc/table-list/Properties.js +25 -0
- package/es/cc/table-list/row/Properties.js +44 -0
- package/es/index.js +2 -1
- package/es/library/custom-component/adapters/gateways/event-manager/EventManager.js +116 -4
- package/es/library/custom-component/applications/interfaces/gateways/ISchemaValidator.js +1 -0
- package/es/library/custom-component/applications/usecases/InitializeUseCase.js +3 -2
- package/es/library/custom-component/applications/usecases/UpdatePropertyUseCase.js +3 -2
- package/es/library/custom-component/domain/entities/Component.js +16 -3
- package/es/library/custom-component/domain/entities/Properties.js +19 -1
- package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +36 -1
- package/es/library/custom-component/frameworks/ui/CreateCustomComponent.js +23 -11
- package/es/library/custom-component/frameworks/ui/DependencyFactory.js +4 -3
- package/es/library/dot/components/table-list/frameworks/hooks/useDropIndicator.js +8 -0
- package/es/library/dot/components/table-list/frameworks/hooks/useRowData.js +15 -0
- package/es/library/dot/components/table-list/frameworks/hooks/useTableRowReorder.js +105 -0
- package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +85 -15
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +240 -1
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +28 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Rows.js +25 -9
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -2
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +50 -8
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowSelection.js +6 -1
- package/es/library/dot/components/table-list/frameworks/utils/getHeaderClasses.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/getTableListClassName.js +37 -0
- package/es/library/dot/components/table-list/frameworks/utils/reOrder.js +90 -0
- package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +1 -1
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +96 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/EventHandlersFactory.js +11 -3
- package/es/platform/client-actions/template-resolver/index.js +1 -0
- package/es/platform/client-actions/translators/context-resolver/index.js +6 -6
- package/es/platform/components/table-connected/adapters/controllers/ColumnChooserOpenedController.js +1 -1
- package/es/platform/components/table-connected/adapters/controllers/ReOrderFinishController.js +21 -0
- package/es/platform/components/table-connected/adapters/resources/ErrorPrinter.js +20 -0
- package/es/platform/components/table-connected/adapters/resources/SmartTableResource.js +85 -0
- package/es/platform/components/table-connected/frameworks/ErrorEventHandlersFactory.js +126 -0
- package/es/platform/components/table-connected/frameworks/EventHandlersFactory.js +39 -3
- package/es/platform/components/table-connected/frameworks/ListSdkFactory.js +4 -2
- package/es/platform/components/table-connected/frameworks/TableConnectedFactory.js +2 -0
- package/es/platform/components/table-connected/frameworks/TableConnectedView.js +8 -2
- package/es/platform/data-source/http-template/reOrderRecord.js +44 -0
- package/es/platform/data-source/index.js +2 -0
- package/es/platform/sdk/application/interfaces/gateways/AbstractResource.js +1 -2
- package/es/platform/sdk/domain/entities/ResourceManager.js +1 -1
- package/es/platform/zdata-source/domain/entities/DataSource.js +18 -12
- package/es/platform/zfield/domain/entities/fields-manager/FieldsManager.js +7 -1
- package/es/platform/zform/adapters/presenter/FormTranslator.js +6 -127
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +32 -0
- package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +20 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +21 -0
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +29 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +27 -0
- package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +30 -0
- package/es/platform/zform/adapters/presenter/translators/fields/index.js +15 -0
- package/es/platform/zform/applications/usecases/MyFormSuccessUseCase.js +3 -1
- package/es/platform/zform/domain/ZField.js +61 -16
- package/es/platform/zform/domain/ZSection.js +20 -7
- package/es/platform/zhttp/applications/usecases/FetchUseCase.js +111 -66
- package/es/platform/zlist/adapters/controllers/FieldExecuteFailedController.js +25 -0
- package/es/platform/zlist/adapters/controllers/ReOrderController.js +25 -0
- package/es/platform/zlist/adapters/controllers/ReOrderFailedController.js +26 -0
- package/es/platform/zlist/adapters/gateways/Repository.js +12 -2
- package/es/platform/zlist/adapters/gateways/Service.js +8 -0
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +15 -4
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +11 -12
- package/es/platform/zlist/adapters/presenters/translators/EmptyViewModel.js +2 -1
- package/es/platform/zlist/adapters/presenters/translators/Header.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/HeadersTranslator.js +3 -2
- package/es/platform/zlist/adapters/presenters/translators/fields/CurrencyFieldTranslator.js +1 -0
- package/es/platform/zlist/adapters/presenters/translators/fields/FormulaFieldTranslator.js +3 -0
- package/es/platform/zlist/adapters/presenters/utils/DefaultClientActions.js +1 -1
- package/es/platform/zlist/applications/entities-factory/ListFactory.js +3 -2
- package/es/platform/zlist/applications/interfaces/input/ReOrderRecordUseCaseInput.js +1 -0
- package/es/platform/zlist/applications/usecases/FetchMoreUseCase.js +1 -1
- package/es/platform/zlist/applications/usecases/ReOrderFailedUseCase.js +22 -0
- package/es/platform/zlist/applications/usecases/ReOrderUseCase.js +25 -0
- package/es/platform/zlist/applications/usecases/RecordExecuteFailedUseCase.js +3 -2
- package/es/platform/zlist/applications/usecases/RecordSuccessCallbackUsecase.js +24 -3
- package/es/platform/zlist/domain/entities/List.js +61 -48
- package/es/platform/zlist/domain/entities/ListErrorState.js +167 -0
- package/es/platform/zlist/frameworks/EventHandlersFactory.js +13 -3
- package/es/platform/zlist/frameworks/ZListBehaviourFactory.js +6 -0
- package/es/platform/zrecord/domain/entities/GetReOrderRecordsStrategy.js +40 -0
- package/es/platform/zrecord/domain/entities/RecordsManager.js +3 -1
- package/package.json +6 -3
|
@@ -3,7 +3,7 @@ import ClientActionsTranslator from "../../../../client-actions/translators/clie
|
|
|
3
3
|
import { SortOrder } from "../../../../zlist/domain/entities/interfaces/Properties";
|
|
4
4
|
import { i18NProviderUtils } from '@zohodesk/i18n';
|
|
5
5
|
|
|
6
|
-
function HeaderTranslator(field, actions, context, modifiedWidths, sortBy) {
|
|
6
|
+
function HeaderTranslator(field, actions, context, modifiedWidths, sortBy, records) {
|
|
7
7
|
const {
|
|
8
8
|
id,
|
|
9
9
|
name,
|
|
@@ -15,7 +15,8 @@ function HeaderTranslator(field, actions, context, modifiedWidths, sortBy) {
|
|
|
15
15
|
sort: translateSortBy(field.id, sortBy)
|
|
16
16
|
};
|
|
17
17
|
const transformedActions = ClientActionsTranslator.transform(actions, { ...context,
|
|
18
|
-
field: newField
|
|
18
|
+
field: newField,
|
|
19
|
+
recordsLength: records.length.toString()
|
|
19
20
|
});
|
|
20
21
|
const width = modifiedWidths[name];
|
|
21
22
|
return {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import HeaderTranslator from "./Header";
|
|
2
2
|
export default class HeadersTranslator {
|
|
3
|
-
constructor(fields, actions, context, modifiedWidths, sortBy) {
|
|
3
|
+
constructor(fields, actions, context, modifiedWidths, sortBy, records) {
|
|
4
4
|
this.fields = fields;
|
|
5
5
|
this.actions = actions;
|
|
6
6
|
this.context = context;
|
|
7
7
|
this.modifiedWidths = modifiedWidths;
|
|
8
8
|
this.sortBy = sortBy;
|
|
9
|
+
this.records = records;
|
|
9
10
|
this.pipe = this.pipe.bind(this);
|
|
10
11
|
}
|
|
11
12
|
|
|
@@ -14,7 +15,7 @@ export default class HeadersTranslator {
|
|
|
14
15
|
return [];
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
return this.fields.map(field => HeaderTranslator(field, this.actions, this.context, this.modifiedWidths, this.sortBy));
|
|
18
|
+
return this.fields.map(field => HeaderTranslator(field, this.actions, this.context, this.modifiedWidths, this.sortBy, this.records));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
pipe(viewModel) {
|
|
@@ -7,9 +7,10 @@ class ListFactory {
|
|
|
7
7
|
sortBy,
|
|
8
8
|
query,
|
|
9
9
|
context,
|
|
10
|
-
|
|
10
|
+
errorState,
|
|
11
|
+
isReOrderLoading
|
|
11
12
|
} = input;
|
|
12
|
-
return new List(limit, sortBy, query, context,
|
|
13
|
+
return new List(limit, sortBy, query, context, isReOrderLoading, errorState);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,7 +10,7 @@ class FetchMoreUseCase extends AbstractUseCase {
|
|
|
10
10
|
} = this.dependencies;
|
|
11
11
|
const list = repository.getList();
|
|
12
12
|
|
|
13
|
-
if (!list.
|
|
13
|
+
if (!list.hasFetchingFailedInMoreRecords()) {
|
|
14
14
|
dispatch(list.createMoreRecordFetchAction());
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class ReOrderFailedUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
metaData
|
|
7
|
+
} = input;
|
|
8
|
+
const {
|
|
9
|
+
repository,
|
|
10
|
+
presenter
|
|
11
|
+
} = this.dependencies;
|
|
12
|
+
const list = repository.getList();
|
|
13
|
+
|
|
14
|
+
if (metaData.isReOrder) {
|
|
15
|
+
list.reOrderEnded();
|
|
16
|
+
presenter.updateView(list.toObject());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default ReOrderFailedUseCase;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase";
|
|
2
|
+
|
|
3
|
+
class ReOrderUseCase extends AbstractUseCase {
|
|
4
|
+
execute(input) {
|
|
5
|
+
const {
|
|
6
|
+
dispatch,
|
|
7
|
+
newIndex,
|
|
8
|
+
oldIndex
|
|
9
|
+
} = input;
|
|
10
|
+
const {
|
|
11
|
+
repository,
|
|
12
|
+
presenter
|
|
13
|
+
} = this.dependencies;
|
|
14
|
+
const list = repository.getList();
|
|
15
|
+
list.reOrderStarted();
|
|
16
|
+
presenter.updateView(list.toObject());
|
|
17
|
+
dispatch(list.getReOrderRecordAction({
|
|
18
|
+
newIndex,
|
|
19
|
+
oldIndex
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default ReOrderUseCase;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import AbstractUseCase from "./AbstractUseCase";
|
|
1
|
+
import AbstractUseCase from "./AbstractUseCase"; // TODO Rename this file to ApiFailedHandleUseCase.ts
|
|
2
2
|
|
|
3
3
|
class RecordExecuteFailedUseCase extends AbstractUseCase {
|
|
4
4
|
execute(input) {
|
|
@@ -12,8 +12,9 @@ class RecordExecuteFailedUseCase extends AbstractUseCase {
|
|
|
12
12
|
presenter
|
|
13
13
|
} = this.dependencies;
|
|
14
14
|
const list = repository.getList();
|
|
15
|
-
|
|
15
|
+
list.processApiError(payload, metaData);
|
|
16
16
|
presenter.updateView(list.toObject());
|
|
17
|
+
const actions = list.generateApiErrorEvent(payload, metaData);
|
|
17
18
|
actions.forEach(action => {
|
|
18
19
|
dispatch(action);
|
|
19
20
|
});
|
|
@@ -1,18 +1,39 @@
|
|
|
1
|
+
import { SET_RECORDS } from "../../../../bc/zrecord/Constants";
|
|
1
2
|
import AbstractUseCase from "./AbstractUseCase";
|
|
2
3
|
|
|
3
4
|
class RecordSuccessCallbackUsecase extends AbstractUseCase {
|
|
4
|
-
execute(
|
|
5
|
-
|
|
5
|
+
execute(_ref) {
|
|
6
|
+
var _metaData$sourceMetaD;
|
|
7
|
+
|
|
8
|
+
let {
|
|
6
9
|
dispatch,
|
|
7
10
|
payload,
|
|
8
11
|
metaData
|
|
9
|
-
} =
|
|
12
|
+
} = _ref;
|
|
10
13
|
const {
|
|
11
14
|
repository,
|
|
12
15
|
presenter
|
|
13
16
|
} = this.dependencies;
|
|
14
17
|
const list = repository.getList();
|
|
15
18
|
|
|
19
|
+
if ((_metaData$sourceMetaD = metaData.sourceMetaData) !== null && _metaData$sourceMetaD !== void 0 && _metaData$sourceMetaD.isReOrder) {
|
|
20
|
+
list.reOrderEnded();
|
|
21
|
+
presenter.updateView(list.toObject()); // convert to separate use-case
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
oldIndex,
|
|
25
|
+
newIndex
|
|
26
|
+
} = payload.response;
|
|
27
|
+
const records = repository.getRecords();
|
|
28
|
+
const reordered = oldIndex === newIndex ? records : list.arrayMoveImmutable(records, oldIndex, newIndex);
|
|
29
|
+
dispatch({
|
|
30
|
+
type: SET_RECORDS,
|
|
31
|
+
payload: {
|
|
32
|
+
records: reordered
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
if (list.isAcknowledgeBySortBy(metaData)) {
|
|
17
38
|
list.setSortBy(metaData);
|
|
18
39
|
presenter.updateView(list.toObject());
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
import { RECORD_EXECUTE, RECORD_FETCH_MORE, RECORD_REFETCH, RecordApiActionName } from "../../../../bc/zrecord/Constants";
|
|
2
2
|
import { FIELD_EXECUTE, FIELD_REFETCH } from "../../../../bc/zfield/Constants";
|
|
3
|
-
import {
|
|
3
|
+
import { ZLIST_RECORD_DELETE_SUCCEEDED, ZLIST_RECORD_UPDATE_SUCCEEDED } from "../../../../bc/zlist/Constants";
|
|
4
4
|
import { CLIENTACTION_BEHAVIOUR_EXECUTE } from "../../../client-actions/bc/zclient-actions/Constants";
|
|
5
5
|
import { SmartTableConstants } from "../../../../cc/table-connected";
|
|
6
6
|
import SortBy from "./SortBy";
|
|
7
7
|
|
|
8
8
|
class List {
|
|
9
|
-
constructor(limit, sortBy, query, context,
|
|
9
|
+
constructor(limit, sortBy, query, context, isReOrderLoading, errorState) {
|
|
10
10
|
this.limit = limit;
|
|
11
11
|
this.sortBy = sortBy;
|
|
12
12
|
this.query = query;
|
|
13
13
|
this.context = context;
|
|
14
|
-
this.
|
|
14
|
+
this.isReOrderLoading = isReOrderLoading;
|
|
15
|
+
this.errorState = errorState;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
toObject() {
|
|
18
19
|
return {
|
|
19
20
|
sortBy: this.sortBy.toObject(),
|
|
20
|
-
|
|
21
|
+
isReOrderLoading: this.isReOrderLoading,
|
|
22
|
+
errorState: this.errorState.toObject()
|
|
21
23
|
};
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
reOrderStarted() {
|
|
27
|
+
this.isReOrderLoading = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
reOrderEnded() {
|
|
31
|
+
this.isReOrderLoading = false;
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
setSortBy(sortBy) {
|
|
25
35
|
this.sortBy = new SortBy(sortBy.id, sortBy.name, sortBy.order);
|
|
26
36
|
}
|
|
@@ -107,9 +117,8 @@ class List {
|
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
if (this.shallowDiff(preQuery, curQuery)) {
|
|
110
|
-
return [this.createRecordsRefetchAction(), this.createAvailableFieldsFetchAction(), this.createSelectedFieldsFetchAction() // TODO: this.createAvailableFieldsRefetchAction(),
|
|
120
|
+
return [this.createRecordsRefetchAction(), this.createAvailableFieldsFetchAction(), this.createSelectedFieldsFetchAction()]; // TODO: this.createAvailableFieldsRefetchAction(),
|
|
111
121
|
// TODO: this.createSelectedFieldsRefetchAction()
|
|
112
|
-
];
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
return [];
|
|
@@ -221,51 +230,16 @@ class List {
|
|
|
221
230
|
return actions;
|
|
222
231
|
}
|
|
223
232
|
|
|
224
|
-
|
|
225
|
-
return this.
|
|
233
|
+
hasFetchingFailedInMoreRecords() {
|
|
234
|
+
return this.errorState.hasFetchingFailedInMoreRecords();
|
|
226
235
|
}
|
|
227
236
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
} = metaData;
|
|
232
|
-
const actions = [];
|
|
233
|
-
|
|
234
|
-
if (actionName === RecordApiActionName.GET_RECORDS) {
|
|
235
|
-
if (metaData.isAppend) {
|
|
236
|
-
this.errorRecordFailed = true;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (actionName === RecordApiActionName.DELETE_RECORD) {
|
|
241
|
-
const {
|
|
242
|
-
recordId,
|
|
243
|
-
error
|
|
244
|
-
} = payload;
|
|
245
|
-
actions.push({
|
|
246
|
-
type: ZLIST_RECORD_DELETE_FAILED,
|
|
247
|
-
payload: {
|
|
248
|
-
recordId,
|
|
249
|
-
error
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (actionName === RecordApiActionName.UPDATE_RECORD) {
|
|
255
|
-
const {
|
|
256
|
-
recordId,
|
|
257
|
-
error
|
|
258
|
-
} = payload;
|
|
259
|
-
actions.push({
|
|
260
|
-
type: ZLIST_RECORD_UPDATE_FAILED,
|
|
261
|
-
payload: {
|
|
262
|
-
recordId,
|
|
263
|
-
error
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
}
|
|
237
|
+
processApiError(payload, metaData) {
|
|
238
|
+
return this.errorState.processApiError(payload, metaData);
|
|
239
|
+
}
|
|
267
240
|
|
|
268
|
-
|
|
241
|
+
generateApiErrorEvent(payload, metaData) {
|
|
242
|
+
return this.errorState.generateApiErrorEvent(payload, metaData);
|
|
269
243
|
}
|
|
270
244
|
|
|
271
245
|
getDeleteMultipleRecordAction(recordIds) {
|
|
@@ -282,6 +256,28 @@ class List {
|
|
|
282
256
|
};
|
|
283
257
|
}
|
|
284
258
|
|
|
259
|
+
getReOrderRecordAction(_ref2) {
|
|
260
|
+
let {
|
|
261
|
+
newIndex,
|
|
262
|
+
oldIndex
|
|
263
|
+
} = _ref2;
|
|
264
|
+
const props = this.createApiProps();
|
|
265
|
+
return {
|
|
266
|
+
type: RECORD_EXECUTE,
|
|
267
|
+
metaData: {
|
|
268
|
+
isReOrder: true
|
|
269
|
+
},
|
|
270
|
+
payload: {
|
|
271
|
+
actionName: RecordApiActionName.GET_REORDERRECORD,
|
|
272
|
+
props: { ...props,
|
|
273
|
+
newIndex,
|
|
274
|
+
oldIndex
|
|
275
|
+
},
|
|
276
|
+
apiName: 'records'
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
285
281
|
createMoreRecordFetchAction() {
|
|
286
282
|
const props = this.createApiProps();
|
|
287
283
|
return {
|
|
@@ -348,6 +344,23 @@ class List {
|
|
|
348
344
|
};
|
|
349
345
|
}
|
|
350
346
|
|
|
347
|
+
arrayMoveImmutable(data, fromIndex, toIndex) {
|
|
348
|
+
if (fromIndex === toIndex) {
|
|
349
|
+
return [...data];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const newOrder = [...data];
|
|
353
|
+
const startIndex = fromIndex < 0 ? newOrder.length + fromIndex : fromIndex;
|
|
354
|
+
const endIndex = toIndex < 0 ? newOrder.length + toIndex : toIndex;
|
|
355
|
+
|
|
356
|
+
if (startIndex >= 0 && startIndex < newOrder.length) {
|
|
357
|
+
const [item] = newOrder.splice(startIndex, 1);
|
|
358
|
+
newOrder.splice(endIndex, 0, item);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return newOrder;
|
|
362
|
+
}
|
|
363
|
+
|
|
351
364
|
createAvailableFieldsRefetchAction() {
|
|
352
365
|
const props = this.createApiProps();
|
|
353
366
|
return {
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { RecordApiActionName } from "../../../../bc/zrecord/Constants";
|
|
2
|
+
import { ZLIST_FETCH_MORE_RECORDS_FAILED, ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED, ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED, ZLIST_INITIAL_RECORDS_FETCH_FAILED, ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED, ZLIST_RECORD_DELETE_FAILED, ZLIST_RECORD_UPDATE_FAILED } from "../../../../bc/zlist/Constants";
|
|
3
|
+
import { ClientActionApiActionName } from "../../../client-actions/bc/zclient-actions/Constants";
|
|
4
|
+
import FieldApiName from "../../../zfield/domain/entities/interfaces/FieldApiName";
|
|
5
|
+
|
|
6
|
+
class ListErrorState {
|
|
7
|
+
constructor(errorState) {
|
|
8
|
+
this.errorState = errorState;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toObject() {
|
|
12
|
+
return this.errorState;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
hasFetchingFailedInMoreRecords() {
|
|
16
|
+
return this.errorState.hasFetchingFailedInMoreRecords;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
processApiError(payload, metaData) {
|
|
20
|
+
const {
|
|
21
|
+
actionName
|
|
22
|
+
} = metaData;
|
|
23
|
+
|
|
24
|
+
if (FieldApiName.AVAILABLE_FIELDS === actionName || FieldApiName.SELECTED_FIELDS === actionName) {
|
|
25
|
+
this.errorState = { ...this.errorState,
|
|
26
|
+
canErrorPage: true,
|
|
27
|
+
shouldClearRecords: true
|
|
28
|
+
};
|
|
29
|
+
} else if (RecordApiActionName.GET_RECORDS === actionName) {
|
|
30
|
+
if (metaData.isAppend !== true) {
|
|
31
|
+
this.errorState = { ...this.errorState,
|
|
32
|
+
canErrorPage: true,
|
|
33
|
+
shouldClearRecords: true
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
this.errorState = { ...this.errorState,
|
|
37
|
+
hasFetchingFailedInMoreRecords: true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
generateApiErrorEvent(payload, metaData) {
|
|
44
|
+
const {
|
|
45
|
+
actionName
|
|
46
|
+
} = metaData;
|
|
47
|
+
const actions = [];
|
|
48
|
+
|
|
49
|
+
function push(action) {
|
|
50
|
+
if (action) {
|
|
51
|
+
actions.push(action);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
push(this.getAvailableFieldsFailedAction(payload, actionName));
|
|
56
|
+
push(this.getSelectedFieldsFailedAction(payload, actionName));
|
|
57
|
+
push(this.getClientActionsFailedAction(payload, actionName));
|
|
58
|
+
push(this.getGetRecordsFailedAction(payload, metaData, actionName));
|
|
59
|
+
push(this.getDeleteRecordFailedAction(payload, actionName));
|
|
60
|
+
push(this.getUpdateRecordFailedAction(payload, actionName));
|
|
61
|
+
return actions;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getAvailableFieldsFailedAction(payload, actionName) {
|
|
65
|
+
if (FieldApiName.AVAILABLE_FIELDS === actionName) {
|
|
66
|
+
//TOTO return { type: ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED, payload, metaData };
|
|
67
|
+
return {
|
|
68
|
+
type: ZLIST_INITIAL_AVAILABLE_FIELDS_FETCH_FAILED,
|
|
69
|
+
payload
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getSelectedFieldsFailedAction(payload, actionName) {
|
|
77
|
+
if (FieldApiName.SELECTED_FIELDS === actionName) {
|
|
78
|
+
//TOTO return { type: ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED, payload, metaData };
|
|
79
|
+
return {
|
|
80
|
+
type: ZLIST_INITIAL_SELECTED_FIELDS_FETCH_FAILED,
|
|
81
|
+
payload
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getClientActionsFailedAction(payload, actionName) {
|
|
89
|
+
if (ClientActionApiActionName.GET_CLIENTACTIONS === actionName) {
|
|
90
|
+
//TOTO return { type: ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED, payload, metaData };
|
|
91
|
+
return {
|
|
92
|
+
type: ZLIST_INITIAL_CLIENT_ACTIONS_FETCH_FAILED,
|
|
93
|
+
payload
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getGetRecordsFailedAction(payload, metaData, actionName) {
|
|
101
|
+
if (RecordApiActionName.GET_RECORDS === actionName) {
|
|
102
|
+
if (metaData.isAppend !== true) {
|
|
103
|
+
return {
|
|
104
|
+
type: ZLIST_INITIAL_RECORDS_FETCH_FAILED,
|
|
105
|
+
payload,
|
|
106
|
+
metaData
|
|
107
|
+
};
|
|
108
|
+
} else {
|
|
109
|
+
const {
|
|
110
|
+
from,
|
|
111
|
+
limit
|
|
112
|
+
} = metaData.props;
|
|
113
|
+
return {
|
|
114
|
+
type: ZLIST_FETCH_MORE_RECORDS_FAILED,
|
|
115
|
+
payload: { ...payload,
|
|
116
|
+
from,
|
|
117
|
+
limit
|
|
118
|
+
},
|
|
119
|
+
metaData
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
getDeleteRecordFailedAction(payload, actionName) {
|
|
128
|
+
if (actionName === RecordApiActionName.DELETE_RECORD) {
|
|
129
|
+
const {
|
|
130
|
+
recordId,
|
|
131
|
+
error
|
|
132
|
+
} = payload;
|
|
133
|
+
return {
|
|
134
|
+
type: ZLIST_RECORD_DELETE_FAILED,
|
|
135
|
+
payload: {
|
|
136
|
+
recordId,
|
|
137
|
+
error
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
getUpdateRecordFailedAction(payload, actionName) {
|
|
146
|
+
if (actionName === RecordApiActionName.UPDATE_RECORD) {
|
|
147
|
+
const {
|
|
148
|
+
recordId,
|
|
149
|
+
error,
|
|
150
|
+
record
|
|
151
|
+
} = payload;
|
|
152
|
+
return {
|
|
153
|
+
type: ZLIST_RECORD_UPDATE_FAILED,
|
|
154
|
+
payload: {
|
|
155
|
+
recordId,
|
|
156
|
+
error,
|
|
157
|
+
record
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export default ListErrorState;
|
|
@@ -4,7 +4,7 @@ import Service from "../adapters/gateways/Service";
|
|
|
4
4
|
import Repository from "../adapters/gateways/Repository";
|
|
5
5
|
import MountController from "../adapters/controllers/MountController";
|
|
6
6
|
import PropertiesChangeController from "../adapters/controllers/PropertiesChangeController";
|
|
7
|
-
import { ZLIST_DELETE_RECORD, ZLIST_DELETE_RECORDS, ZLIST_FETCH_MORE, ZLIST_RECORD_DELETE_SUCCEEDED, ZLIST_RECORD_UPDATE, ZLIST_RECORD_UPDATE_SUCCEEDED, ZLIST_SORT } from "../../../bc/zlist/Constants";
|
|
7
|
+
import { ZLIST_DELETE_RECORD, ZLIST_DELETE_RECORDS, ZLIST_FETCH_MORE, ZLIST_RECORD_DELETE_SUCCEEDED, ZLIST_RECORD_UPDATE, ZLIST_RECORD_UPDATE_SUCCEEDED, ZLIST_SORT, ZLIST_RECORD_REORDER, ZLIST_RECORD_REORDER_FAILED } from "../../../bc/zlist/Constants";
|
|
8
8
|
import FetchMoreController from "../adapters/controllers/FetchMoreController";
|
|
9
9
|
import SortController from "../adapters/controllers/SortController";
|
|
10
10
|
import FieldChangeController from "../adapters/controllers/FieldChangeController";
|
|
@@ -20,6 +20,11 @@ import UpdateSuccessController from "../adapters/controllers/UpdateSuccessContro
|
|
|
20
20
|
import DeleteSuccessController from "../adapters/controllers/DeleteSuccessController";
|
|
21
21
|
import Presenter from "../adapters/presenters/Presenters";
|
|
22
22
|
import RecordSuccessCallbackController from "../adapters/controllers/RecordSuccessCallbackController";
|
|
23
|
+
import ReOrderController from "../adapters/controllers/ReOrderController";
|
|
24
|
+
import ReOrderFailedController from "../adapters/controllers/ReOrderFailedController";
|
|
25
|
+
import { FIELD_FETCH_FAILURE } from "../../../bc/zfield/Constants";
|
|
26
|
+
import FieldExecuteFailedController from "../adapters/controllers/FieldExecuteFailedController";
|
|
27
|
+
import { CLIENTACTION_EXECUTE_FAILED } from "../../client-actions/bc/zclient-actions/Constants";
|
|
23
28
|
export default class ActionHandlersFactory {
|
|
24
29
|
static create() {
|
|
25
30
|
const repository = new Repository();
|
|
@@ -37,15 +42,20 @@ export default class ActionHandlersFactory {
|
|
|
37
42
|
[ZLIST_RECORD_UPDATE]: new RecordUpdateController(service).handle,
|
|
38
43
|
[ZLIST_DELETE_RECORD]: new DeleteSingleRecordController(service).handle,
|
|
39
44
|
[ZLIST_DELETE_RECORDS]: new DeleteMultipleRecordController(service).handle,
|
|
45
|
+
[FIELD_FETCH_FAILURE]: new FieldExecuteFailedController(service).handle,
|
|
46
|
+
// ({ dispatch, action }) => dispatch({ type: 'SMART_TABLE#RECORD_EXECUTE_FAILED', payload: action.payload }),
|
|
40
47
|
[TableListConstants.TABLE_LIST_FIELD_CHANGED]: new FieldChangeController(service).handle,
|
|
41
48
|
[RECORD_EXECUTE_SUCCEEDED]: new RecordExecuteSucceededController(service).handle,
|
|
42
49
|
[RECORD_EXECUTE_FAILED]: new RecordExecuteFailedController(service).handle,
|
|
50
|
+
[CLIENTACTION_EXECUTE_FAILED]: new RecordExecuteFailedController(service).handle,
|
|
43
51
|
[ZLIST_SORT]: new SortController(service).handle,
|
|
44
52
|
[RECORD_EXECUTE_SUCCESS_CALLBACK]: new RecordSuccessCallbackController(service).handle,
|
|
45
53
|
[ZLIST_RECORD_UPDATE_SUCCEEDED]: new UpdateSuccessController(service).handle,
|
|
46
54
|
// ({ dispatch, action }) => dispatch({ type: 'SMART_TABLE#RECORD_UPDATED', payload: action.payload }),
|
|
47
|
-
[ZLIST_RECORD_DELETE_SUCCEEDED]: new DeleteSuccessController(service).handle
|
|
48
|
-
|
|
55
|
+
[ZLIST_RECORD_DELETE_SUCCEEDED]: new DeleteSuccessController(service).handle,
|
|
56
|
+
// ({ dispatch, action }) => dispatch({ type: 'SMART_TABLE#RECORD_DELETED', payload: { id: action.payload.id } })
|
|
57
|
+
[ZLIST_RECORD_REORDER]: new ReOrderController(service).handle,
|
|
58
|
+
[ZLIST_RECORD_REORDER_FAILED]: new ReOrderFailedController(service).handle
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
61
|
|
|
@@ -9,6 +9,12 @@ export default class ZListBehaviourFactory {
|
|
|
9
9
|
id: '',
|
|
10
10
|
name: '',
|
|
11
11
|
order: 'none'
|
|
12
|
+
},
|
|
13
|
+
isReOrderLoading: false,
|
|
14
|
+
errorState: {
|
|
15
|
+
canErrorPage: false,
|
|
16
|
+
shouldClearRecords: false,
|
|
17
|
+
hasFetchingFailedInMoreRecords: false
|
|
12
18
|
}
|
|
13
19
|
}),
|
|
14
20
|
eventHandlers: EventHandlersFactory.create(),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RECORD_EXECUTE_FAILED, RECORD_EXECUTE_SUCCEEDED, RECORD_EXECUTE_SUCCEEDED_NO_CONTENT } from "../../../../bc/zrecord/Constants";
|
|
2
|
+
export default class ReOrderRecordStrategy {
|
|
3
|
+
createSuccessEvents(response, metaData) {
|
|
4
|
+
const events = [];
|
|
5
|
+
let {
|
|
6
|
+
oldIndex,
|
|
7
|
+
newIndex
|
|
8
|
+
} = metaData.props;
|
|
9
|
+
events.push({
|
|
10
|
+
type: RECORD_EXECUTE_SUCCEEDED,
|
|
11
|
+
payload: {
|
|
12
|
+
oldIndex,
|
|
13
|
+
newIndex
|
|
14
|
+
},
|
|
15
|
+
metaData
|
|
16
|
+
});
|
|
17
|
+
return events;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
createNoContentEvents(metaData) {
|
|
21
|
+
const events = [];
|
|
22
|
+
events.push({
|
|
23
|
+
type: RECORD_EXECUTE_SUCCEEDED_NO_CONTENT,
|
|
24
|
+
payload: {},
|
|
25
|
+
metaData
|
|
26
|
+
});
|
|
27
|
+
return events;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
createFailureEvents(error, metaData) {
|
|
31
|
+
const events = [];
|
|
32
|
+
events.push({
|
|
33
|
+
type: RECORD_EXECUTE_FAILED,
|
|
34
|
+
payload: {},
|
|
35
|
+
metaData
|
|
36
|
+
});
|
|
37
|
+
return events;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
@@ -5,11 +5,13 @@ import UpdateRecordStrategy from "./UpdateRecordStrategy";
|
|
|
5
5
|
import DeleteRecordStrategy from "./DeleteRecordStrategy";
|
|
6
6
|
import DeleteMultipleRecordStrategy from "./DeleteMultipleRecordStrategy";
|
|
7
7
|
import GetRecordsStrategy from "./GetRecordsStrategy";
|
|
8
|
+
import GetReOrderRecordsStrategy from "./GetReOrderRecordsStrategy";
|
|
8
9
|
const recordExecuteStrategiesMap = {
|
|
9
10
|
[RecordApiActionName.UPDATE_RECORD]: new UpdateRecordStrategy(),
|
|
10
11
|
[RecordApiActionName.DELETE_RECORD]: new DeleteRecordStrategy(),
|
|
11
12
|
[RecordApiActionName.DELETE_RECORDS]: new DeleteMultipleRecordStrategy(),
|
|
12
|
-
[RecordApiActionName.GET_RECORDS]: new GetRecordsStrategy()
|
|
13
|
+
[RecordApiActionName.GET_RECORDS]: new GetRecordsStrategy(),
|
|
14
|
+
[RecordApiActionName.GET_REORDERRECORD]: new GetReOrderRecordsStrategy()
|
|
13
15
|
};
|
|
14
16
|
export default class RecordsManager {
|
|
15
17
|
constructor(records) {
|