not-options 0.2.0 → 0.2.2
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/index.js +3 -3
- package/package.json +2 -2
- package/src/const.js +4 -0
- package/src/controllers/common/actions/json.import.export/export.to.json.js +103 -0
- package/src/controllers/common/actions/json.import.export/export.to.json.svelte +19 -0
- package/src/controllers/common/actions/json.import.export/import.from.json.js +139 -0
- package/src/controllers/common/actions/json.import.export/import.from.json.svelte +21 -0
- package/src/controllers/common/index.js +2 -0
- package/src/controllers/common/styles.scss +3 -0
- package/src/controllers/root/ncOptions.js +143 -153
- package/src/locales/en.json +4 -2
- package/src/locales/ru.json +5 -2
- package/src/routes/options.js +354 -292
package/index.js
CHANGED
|
@@ -11,10 +11,10 @@ try{
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
|
-
name: '
|
|
14
|
+
name: require('./src/const').MODULE_NAME,
|
|
15
15
|
paths,
|
|
16
|
-
getMiddleware(
|
|
17
|
-
log
|
|
16
|
+
getMiddleware(){
|
|
17
|
+
log?.info('...options middleware');
|
|
18
18
|
return middleware.bind(this);
|
|
19
19
|
},
|
|
20
20
|
};
|
package/package.json
CHANGED
package/src/const.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import CRUDGenericActionRead from "not-bulma/src/frame/crud/actions/generic/read";
|
|
2
|
+
import UIExportToJSON from "./export.to.json.svelte";
|
|
3
|
+
import { MODULE_NAME, DATA_MODEL_NAME } from "../../../../const.js";
|
|
4
|
+
|
|
5
|
+
const DEFAULT_BREADCRUMB_TAIL = `${MODULE_NAME}:action_export_to_json_title`;
|
|
6
|
+
|
|
7
|
+
class ncaExportToJSON extends CRUDGenericActionRead {
|
|
8
|
+
/**
|
|
9
|
+
* @static {string} ACTION this controller action name, used in URI
|
|
10
|
+
*/
|
|
11
|
+
static get ACTION() {
|
|
12
|
+
return "exportToJSON";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static get deafultBreadcrumbsTail() {
|
|
16
|
+
return DEFAULT_BREADCRUMB_TAIL;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static get breadcrumbsTails() {
|
|
20
|
+
return {
|
|
21
|
+
preset: DEFAULT_BREADCRUMB_TAIL,
|
|
22
|
+
set: DEFAULT_BREADCRUMB_TAIL,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @static {string} MODEL_ACTION network model interface action name, used in API
|
|
28
|
+
*/
|
|
29
|
+
static get MODEL_ACTION_GET() {
|
|
30
|
+
return "exportToJSON";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @static {object} UIConstructor constructor of UI component
|
|
35
|
+
*/
|
|
36
|
+
static get UIConstructor() {
|
|
37
|
+
return UIExportToJSON;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static actionButton(controller) {
|
|
41
|
+
return {
|
|
42
|
+
title: `${MODULE_NAME}:action_export_to_json_title`,
|
|
43
|
+
action() {
|
|
44
|
+
controller.navigateAction(undefined, ncaExportToJSON.ACTION);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static prepareUIOptions(controller, response) {
|
|
50
|
+
const actionName = this.getModelActionName(controller);
|
|
51
|
+
return {
|
|
52
|
+
target: controller.getContainerInnerElement(),
|
|
53
|
+
props: {
|
|
54
|
+
value: response.result,
|
|
55
|
+
actionName,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static async loadData(controller, params) {
|
|
61
|
+
return await controller
|
|
62
|
+
.getModel(DATA_MODEL_NAME, {
|
|
63
|
+
moduleName: controller.getModuleName(),
|
|
64
|
+
})
|
|
65
|
+
.$getForModule();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
static async run(controller, params) {
|
|
69
|
+
try {
|
|
70
|
+
//inform that we are starting
|
|
71
|
+
controller.emit(`before:render:${this.ACTION}`, params);
|
|
72
|
+
//if UI for this action exists exiting
|
|
73
|
+
if (this.isUIRendered(controller)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
//setting initial state of breadcrumbs tail
|
|
77
|
+
this.presetBreadcrumbs(controller, params);
|
|
78
|
+
const response = await this.loadData(controller, params);
|
|
79
|
+
if (this.isResponseBad(response)) {
|
|
80
|
+
return controller.showErrorMessage(response);
|
|
81
|
+
}
|
|
82
|
+
//creating action UI component
|
|
83
|
+
const uiComponent = this.UIConstructor;
|
|
84
|
+
this.setUI(
|
|
85
|
+
controller,
|
|
86
|
+
new uiComponent(this.prepareUIOptions(controller, response))
|
|
87
|
+
);
|
|
88
|
+
//bind events to UI
|
|
89
|
+
this.bindUIEvents(controller, params, response);
|
|
90
|
+
//inform that we are ready
|
|
91
|
+
controller.emit(`after:render:${this.ACTION}`, params, response);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
//informing about exception
|
|
94
|
+
controller.emit(`exception:render:${this.ACTION}`, params, e);
|
|
95
|
+
//reporting exception
|
|
96
|
+
controller.report(e);
|
|
97
|
+
//showing error message
|
|
98
|
+
controller.showErrorMessage(e);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default ncaExportToJSON;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let value = {};
|
|
3
|
+
import UIButtons from "not-bulma/src/elements/button/ui.buttons.svelte";
|
|
4
|
+
|
|
5
|
+
$: json = value && JSON.stringify(value, null, 4);
|
|
6
|
+
|
|
7
|
+
const BUTTONS = [
|
|
8
|
+
{
|
|
9
|
+
icon: "clipboard",
|
|
10
|
+
action: () => {
|
|
11
|
+
navigator.clipboard.writeText(json);
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<pre class="not-top-padding">
|
|
18
|
+
<UIButtons values={BUTTONS} right={true} />
|
|
19
|
+
{json}</pre>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import CRUDGenericActionCreate from "not-bulma/src/frame/crud/actions/generic/create";
|
|
2
|
+
import UIImportFromJSON from "./import.from.json.svelte";
|
|
3
|
+
import { MODULE_NAME,DATA_MODEL_NAME } from "./../../../../const.js";
|
|
4
|
+
import notCommon from "not-bulma/src/frame/common";
|
|
5
|
+
|
|
6
|
+
const DEFAULT_BREADCRUMB_TAIL = `${MODULE_NAME}:action_import_from_json_title`;
|
|
7
|
+
|
|
8
|
+
class ncaImportFromJSON extends CRUDGenericActionCreate {
|
|
9
|
+
static get deafultBreadcrumbsTail() {
|
|
10
|
+
return DEFAULT_BREADCRUMB_TAIL;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static get breadcrumbsTails() {
|
|
14
|
+
return {
|
|
15
|
+
preset: DEFAULT_BREADCRUMB_TAIL,
|
|
16
|
+
set: DEFAULT_BREADCRUMB_TAIL,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @static {string} ACTION this controller action name, used in URI
|
|
22
|
+
*/
|
|
23
|
+
static get ACTION() {
|
|
24
|
+
return "importFromJSON";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
static get MODEL_ACTION_GET() {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get MODEL_ACTION_PUT() {
|
|
32
|
+
return "updateForModule";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @static {object} UIConstructor constructor of UI component
|
|
37
|
+
*/
|
|
38
|
+
static get UIConstructor() {
|
|
39
|
+
return UIImportFromJSON;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static prepareUIOptions(controller, value) {
|
|
43
|
+
const actionName = this.getModelActionName(controller);
|
|
44
|
+
return {
|
|
45
|
+
props: {
|
|
46
|
+
actionName,
|
|
47
|
+
},
|
|
48
|
+
target: controller.getContainerInnerElement(),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static actionButton(controller) {
|
|
53
|
+
return {
|
|
54
|
+
action() {
|
|
55
|
+
controller.navigateAction(undefined, ncaImportFromJSON.ACTION);
|
|
56
|
+
},
|
|
57
|
+
title: `${MODULE_NAME}:action_import_from_json_title`,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static async run(controller, params) {
|
|
62
|
+
try {
|
|
63
|
+
//inform that we are starting
|
|
64
|
+
controller.emit(`before:render:${this.ACTION}`, params);
|
|
65
|
+
//if UI for this action exists exiting
|
|
66
|
+
if (this.isUIRendered(controller)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
//setting initial state of breadcrumbs tail
|
|
70
|
+
this.presetBreadcrumbs(controller, params);
|
|
71
|
+
//creating action UI component
|
|
72
|
+
const uiComponent = this.UIConstructor;
|
|
73
|
+
const response = {};
|
|
74
|
+
this.setUI(
|
|
75
|
+
controller,
|
|
76
|
+
new uiComponent(this.prepareUIOptions(controller, response))
|
|
77
|
+
);
|
|
78
|
+
//bind events to UI
|
|
79
|
+
this.bindUIEvents(controller, params, response);
|
|
80
|
+
//inform that we are ready
|
|
81
|
+
controller.emit(`after:render:${this.ACTION}`, params, response);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
//informing about exception
|
|
84
|
+
controller.emit(`exception:render:${this.ACTION}`, params, e);
|
|
85
|
+
//reporting exception
|
|
86
|
+
controller.report(e);
|
|
87
|
+
//showing error message
|
|
88
|
+
controller.showErrorMessage(e);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static bindUIEvents(controller, params, response) {
|
|
93
|
+
if (notCommon.isFunc(controller.goBack)) {
|
|
94
|
+
this.bindUIEvent(controller, "reject", () => controller.goBack());
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this.bindUIEvent(controller, "import", ({ detail }) => {
|
|
98
|
+
ncaImportFromJSON.import(controller, detail);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static setUILoading(controller) {
|
|
103
|
+
this.getUI(controller).$set({ loading: true });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static setUILoaded(controller) {
|
|
107
|
+
this.getUI(controller).$set({ loading: false });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static setUIError(controller, message) {
|
|
111
|
+
this.getUI(controller).$set({ error: message });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static async import(controller, jsonAsText) {
|
|
115
|
+
try {
|
|
116
|
+
ncaImportFromJSON.setUILoading(controller);
|
|
117
|
+
const res = await controller
|
|
118
|
+
.getModel(DATA_MODEL_NAME, {
|
|
119
|
+
moduleName: controller.MODULE_NAME,
|
|
120
|
+
options: jsonAsText
|
|
121
|
+
})
|
|
122
|
+
[`$${ncaImportFromJSON.MODEL_ACTION_PUT}`]();
|
|
123
|
+
if (this.isResponseBad(res)) {
|
|
124
|
+
controller.showErrorMessage(res);
|
|
125
|
+
} else {
|
|
126
|
+
controller.showSuccessMessage(
|
|
127
|
+
"",
|
|
128
|
+
`${MODULE_NAME}:action_import_success`
|
|
129
|
+
);
|
|
130
|
+
controller.navigateAction(undefined, "list", "NORMAL");
|
|
131
|
+
}
|
|
132
|
+
} catch (e) {
|
|
133
|
+
controller.showErrorMessage(e);
|
|
134
|
+
} finally {
|
|
135
|
+
ncaImportFromJSON.setUILoaded(controller);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export default ncaImportFromJSON;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
const dispatch = createEventDispatcher();
|
|
4
|
+
import UITextarea from "not-bulma/src/elements/form/ui.textarea.svelte";
|
|
5
|
+
import UIButton from "not-bulma/src/elements/button/ui.button.svelte";
|
|
6
|
+
import { MODULE_NAME } from "../../../../const.js";
|
|
7
|
+
export let value = "";
|
|
8
|
+
export let loading = false;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<UITextarea bind:value rows={20} disabled={loading} placeholder={""} />
|
|
12
|
+
|
|
13
|
+
<UIButton
|
|
14
|
+
action={() => {
|
|
15
|
+
dispatch("import", value);
|
|
16
|
+
}}
|
|
17
|
+
color={"primary"}
|
|
18
|
+
disabled={loading}
|
|
19
|
+
{loading}
|
|
20
|
+
title={`${MODULE_NAME}:action_import_from_json_title`}
|
|
21
|
+
/>
|
|
@@ -1,176 +1,166 @@
|
|
|
1
|
-
import Validators from
|
|
2
|
-
import {
|
|
3
|
-
Frame
|
|
4
|
-
} from 'not-bulma';
|
|
1
|
+
import Validators from "../common/validators.js";
|
|
2
|
+
import { Frame } from "not-bulma";
|
|
5
3
|
|
|
6
4
|
const notCRUD = Frame.notCRUD;
|
|
7
5
|
|
|
8
|
-
import UIImport from
|
|
6
|
+
import UIImport from "../common/import.svelte";
|
|
7
|
+
import CRUDActionList from "not-bulma/src/frame/crud/actions/list";
|
|
9
8
|
|
|
10
9
|
const LABELS = {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
plural: "Настройки",
|
|
11
|
+
single: "Настройка",
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
const MODEL =
|
|
14
|
+
const MODEL = "options";
|
|
16
15
|
|
|
17
16
|
class ncOptions extends notCRUD {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
},
|
|
91
|
-
}]
|
|
92
|
-
});
|
|
93
|
-
this.start();
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
17
|
+
static MODEL_NAME = MODEL;
|
|
18
|
+
static MODULE_NAME = "";
|
|
19
|
+
constructor(app, params, schemes) {
|
|
20
|
+
super(app, MODEL);
|
|
21
|
+
this.setModuleName("");
|
|
22
|
+
this.setModelName(MODEL);
|
|
23
|
+
this.setOptions("names", LABELS);
|
|
24
|
+
this.setOptions("Validators", Validators);
|
|
25
|
+
this.setOptions("params", params);
|
|
26
|
+
this.setOptions("role", "root");
|
|
27
|
+
this.setOptions("urlSchemes", schemes);
|
|
28
|
+
this.setOptions("list", {
|
|
29
|
+
actions: [
|
|
30
|
+
{
|
|
31
|
+
title: "Экспорт",
|
|
32
|
+
action: this.openExport.bind(this),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: "Импорт",
|
|
36
|
+
action: this.openImport.bind(this),
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
fields: [
|
|
40
|
+
{
|
|
41
|
+
path: ":optionsID",
|
|
42
|
+
title: "ID",
|
|
43
|
+
searchable: true,
|
|
44
|
+
sortable: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
path: ":id",
|
|
48
|
+
title: "Название",
|
|
49
|
+
searchable: true,
|
|
50
|
+
sortable: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: ":value",
|
|
54
|
+
title: "Значение",
|
|
55
|
+
searchable: true,
|
|
56
|
+
sortable: true,
|
|
57
|
+
hideOnMobile: true,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
path: ":active",
|
|
61
|
+
title: "Активна",
|
|
62
|
+
type: "boolean",
|
|
63
|
+
searchable: true,
|
|
64
|
+
sortable: true,
|
|
65
|
+
preprocessor: (value) => {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
value,
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
},
|
|
72
|
+
hideOnMobile: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
path: ":_id",
|
|
76
|
+
title: "Действия",
|
|
77
|
+
type: "button",
|
|
78
|
+
preprocessor: (value) => {
|
|
79
|
+
return CRUDActionList.createActionsButtons(this, value);
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
this.start();
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
96
87
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
createDefault() {
|
|
89
|
+
let newRecord = this.make[this.getModelName()]({
|
|
90
|
+
_id: null,
|
|
91
|
+
id: LABELS.single,
|
|
92
|
+
value: "",
|
|
93
|
+
active: true,
|
|
94
|
+
});
|
|
95
|
+
return newRecord;
|
|
96
|
+
}
|
|
106
97
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
openExport() {
|
|
99
|
+
window.location.assign("/api/options/export");
|
|
100
|
+
/*this.make[this.getModelName()]({}).$export()
|
|
110
101
|
.then((data)=>{
|
|
111
102
|
this.log(data);
|
|
112
103
|
})
|
|
113
104
|
.catch(e => this.error(e));*/
|
|
114
|
-
|
|
105
|
+
}
|
|
115
106
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
107
|
+
closeImportPopup() {
|
|
108
|
+
if (this.ui.import) {
|
|
109
|
+
this.ui.import.$destroy();
|
|
110
|
+
this.ui.import = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
122
113
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
114
|
+
openImport() {
|
|
115
|
+
this.log("import");
|
|
116
|
+
this.closeImportPopup();
|
|
117
|
+
this.ui.import = new UIImport({
|
|
118
|
+
target: document.body,
|
|
119
|
+
});
|
|
120
|
+
this.ui.import.$on("reject", (ev) => {
|
|
121
|
+
if (ev.detail.error) {
|
|
122
|
+
this.error(ev.detail.error);
|
|
123
|
+
}
|
|
124
|
+
this.closeImportPopup();
|
|
125
|
+
});
|
|
126
|
+
this.ui.import.$on("resolve", () => this.closeImportPopup());
|
|
127
|
+
this.ui.import.$on("import", async (ev) => {
|
|
128
|
+
if (ev.detail.options) {
|
|
129
|
+
try {
|
|
130
|
+
let res = await this.requestImport(ev.detail.options);
|
|
131
|
+
this.log(res);
|
|
132
|
+
if (res.status === "ok") {
|
|
133
|
+
if (res.result && res.result.info) {
|
|
134
|
+
this.ui.import.setInfo(res.result.info);
|
|
135
|
+
this.afterImportSuccess(res.result);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
this.error(res.error);
|
|
139
|
+
this.ui.import.setError(res.error);
|
|
140
|
+
}
|
|
141
|
+
} catch (e) {
|
|
142
|
+
this.ui.import.setError(e.message);
|
|
143
|
+
this.error(e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
157
148
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
149
|
+
afterImportSuccess(result) {
|
|
150
|
+
let delay = parseInt(result.shutdown) + 2000;
|
|
151
|
+
this.refresh(delay);
|
|
152
|
+
setTimeout(() => this.closeImportPopup(), delay);
|
|
153
|
+
}
|
|
163
154
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
getItemTitle(item) {
|
|
171
|
-
return `${item.optionsID}#${item.id}`;
|
|
172
|
-
}
|
|
155
|
+
requestImport(data) {
|
|
156
|
+
return this.make[this.getModelName()]({
|
|
157
|
+
options: data,
|
|
158
|
+
}).$import();
|
|
159
|
+
}
|
|
173
160
|
|
|
161
|
+
getItemTitle(item) {
|
|
162
|
+
return `${item.optionsID}#${item.id}`;
|
|
163
|
+
}
|
|
174
164
|
}
|
|
175
165
|
|
|
176
166
|
export default ncOptions;
|
package/src/locales/en.json
CHANGED
package/src/locales/ru.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"title": "Модуль настроек",
|
|
3
|
-
"document_not_found": "Документ не найден"
|
|
4
|
-
|
|
3
|
+
"document_not_found": "Документ не найден",
|
|
4
|
+
"action_export_to_json_title": "Экспорт в JSON",
|
|
5
|
+
"action_import_from_json_title": "Импорт из JSON",
|
|
6
|
+
"action_import_success": "Импорт успешно завершен!"
|
|
7
|
+
}
|