not-bulma 1.0.61 → 1.0.63

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-bulma",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "not-* family UI components on Bulma CSS Framework",
5
5
  "main": "src/index.js",
6
6
  "svelte": "src/index.js",
@@ -59,7 +59,7 @@
59
59
  "bulma-pageloader": "*",
60
60
  "bulma-slider": "*",
61
61
  "bulma-switch": "^2.0.4",
62
- "core-js": "^3.27.2",
62
+ "core-js": "^3.29.1",
63
63
  "mocha": "^10.2.0",
64
64
  "not-path": "^1.0.4",
65
65
  "not-validation": "^0.0.8",
@@ -68,70 +68,70 @@
68
68
  "wolfy87-eventemitter": "^5.2.9"
69
69
  },
70
70
  "devDependencies": {
71
- "@babel/core": "^7.20.12",
71
+ "@babel/core": "^7.21.3",
72
72
  "@babel/plugin-proposal-class-properties": "^7.18.6",
73
73
  "@babel/plugin-proposal-private-methods": "^7.18.6",
74
74
  "@babel/plugin-transform-arrow-functions": "^7.20.7",
75
- "@babel/plugin-transform-runtime": "^7.19.6",
75
+ "@babel/plugin-transform-runtime": "^7.21.0",
76
76
  "@babel/preset-env": "^7.20.2",
77
77
  "@cypress/code-coverage": "^3.10.0",
78
- "autoprefixer": "^10.4.13",
78
+ "autoprefixer": "^10.4.14",
79
79
  "babel-cli": "^6.26.0",
80
80
  "babel-eslint": "^10.1.0",
81
81
  "babel-loader": "^9.1.2",
82
82
  "babel-plugin-istanbul": "^6.1.1",
83
- "connect-mongo": "^4.6.0",
83
+ "connect-mongo": "^5.0.0",
84
84
  "connect-mongodb-session": "^3.1.1",
85
85
  "cors": "^2.8.5",
86
86
  "cypress": "*",
87
- "eslint": "^8.34.0",
88
- "eslint-plugin-storybook": "^0.6.10",
87
+ "eslint": "^8.36.0",
88
+ "eslint-plugin-storybook": "^0.6.11",
89
89
  "eslint-plugin-svelte3": "^4.0.0",
90
90
  "express": "^4.18.2",
91
91
  "express-fileupload": "^1.4.0",
92
92
  "express-session": "^1.17.3",
93
93
  "helmet": "^6.0.1",
94
94
  "ink-docstrap": "^1.3.2",
95
- "ioredis": "^5.3.0",
95
+ "ioredis": "^5.3.1",
96
96
  "istanbul": "^0.4.5",
97
97
  "istanbul-lib-coverage": "^3.2.0",
98
98
  "method-override": "^3.0.0",
99
- "mongodb-memory-server": "^8.11.4",
100
- "mongoose": "^6.9.0",
99
+ "mongodb-memory-server": "^8.12.1",
100
+ "mongoose": "^7.0.2",
101
101
  "node-sass": "^8.0.0",
102
102
  "not-config": "^0.1.5",
103
103
  "not-error": "^0.2.9",
104
- "not-inform": "^0.0.28",
105
- "not-key": "0.0.64",
104
+ "not-inform": "^0.0.30",
105
+ "not-key": "0.0.65",
106
106
  "not-locale": "^0.0.22",
107
107
  "not-log": "0.0.20",
108
- "not-node": "^6.1.9",
108
+ "not-node": "^6.2.11",
109
109
  "not-options": "^0.2.0",
110
- "not-user": "^0.2.131",
111
- "not-ws": "0.1.19",
110
+ "not-user": "^0.2.136",
111
+ "not-ws": "0.1.22",
112
112
  "npm-run-all": "^4.1.5",
113
113
  "nyc": "^15.1.0",
114
114
  "postcss-cli": "^10.1.0",
115
115
  "pug-cli": "^1.0.0-alpha6",
116
- "redis": "^4.6.4",
117
- "rollup": "^3.17.2",
116
+ "redis": "^4.6.5",
117
+ "rollup": "^3.19.1",
118
118
  "rollup-plugin-babel": "^4.4.0",
119
119
  "rollup-plugin-commonjs": "^10.1.0",
120
120
  "rollup-plugin-eslint": "^7.0.0",
121
- "rollup-plugin-filesize": "^9.1.2",
121
+ "rollup-plugin-filesize": "^10.0.0",
122
122
  "rollup-plugin-istanbul": "^4.0.0",
123
123
  "rollup-plugin-node-resolve": "^5.2.0",
124
124
  "rollup-plugin-postcss": "^4.0.2",
125
- "rollup-plugin-sass": "^1.12.17",
125
+ "rollup-plugin-sass": "^1.12.19",
126
126
  "rollup-plugin-sizes": "^1.0.5",
127
- "rollup-plugin-svelte": "^7.1.0",
128
- "sass": "^1.58.0",
127
+ "rollup-plugin-svelte": "^7.1.4",
128
+ "sass": "^1.59.3",
129
129
  "sass-loader": "^13.2.0",
130
130
  "serve": "^14.2.0",
131
- "simple-svelte-autocomplete": "^2.5.1",
132
- "svelte": "^3.55.1",
133
- "svelte-loader": "^3.1.5",
134
- "terser": "^5.16.5"
131
+ "simple-svelte-autocomplete": "^2.5.2",
132
+ "svelte": "^3.57.0",
133
+ "svelte-loader": "^3.1.7",
134
+ "terser": "^5.16.6"
135
135
  },
136
136
  "nyc": {
137
137
  "include": [
@@ -1,6 +1,5 @@
1
- import UIEndlessListEmptyPlaceholder from './ui.endless.list.empty.placeholder.svelte';
2
- import UIEndlessListNavigation from './ui.endless.list.navigation.svelte';
3
- import UIEndlessListSimpleItem from './ui.endless.list.simple.item.svelte';
4
- import UIEndlessList from './ui.endless.list.svelte';
1
+ import UIEndlessListNavigation from "./ui.endless.list.navigation.svelte";
2
+ import UIEndlessListSimpleItem from "./ui.endless.list.simple.item.svelte";
3
+ import UIEndlessList from "./ui.endless.list.svelte";
5
4
 
6
- export {UIEndlessListEmptyPlaceholder, UIEndlessListNavigation, UIEndlessListSimpleItem, UIEndlessList};
5
+ export { UIEndlessListNavigation, UIEndlessListSimpleItem, UIEndlessList };
@@ -3,7 +3,7 @@
3
3
  const dispatch = createEventDispatcher();
4
4
 
5
5
  import UIEndlessListSimpleItem from "./ui.endless.list.simple.item.svelte";
6
- import UIEndlessListEmptyPlaceholder from "..ui.list.empty.placeholder.svelte";
6
+ import UIEndlessListEmptyPlaceholder from "../ui.list.empty.placeholder.svelte";
7
7
  import UIEndlessListNavigation from "./ui.endless.list.navigation.svelte";
8
8
 
9
9
  export let data = {
@@ -1,5 +1,4 @@
1
1
  import {
2
- UIEndlessListEmptyPlaceholder,
3
2
  UIEndlessListNavigation,
4
3
  UIEndlessListSimpleItem,
5
4
  UIEndlessList,
@@ -10,7 +9,6 @@ import UIListItem from "./ui.list.item.svelte";
10
9
  import UIListEmptyPlaceholder from "./ui.list.empty.placeholder.svelte";
11
10
 
12
11
  export {
13
- UIEndlessListEmptyPlaceholder,
14
12
  UIEndlessListNavigation,
15
13
  UIEndlessListSimpleItem,
16
14
  UIEndlessList,
@@ -0,0 +1,39 @@
1
+ <script>
2
+ import UIListItem from "not-bulma/src/elements/list/ui.list.item.svelte";
3
+ import UITitle from "../various/ui.title.svelte";
4
+ export let idFieldName = "id";
5
+ export let items = [];
6
+
7
+ export let itemClasses = "";
8
+
9
+ export let listItemComponent = UIListItem;
10
+ export let listItemComponentProps = {};
11
+
12
+ export let titleComponent = UITitle;
13
+ export let titleComponentProps = { size: 6 };
14
+ export let descriptionComponent;
15
+ export let descriptionComponentProps = {};
16
+ export let imageComponent;
17
+ export let imageComponentProps = {};
18
+ </script>
19
+
20
+ {#each items as item (item[idFieldName])}
21
+ <svelte:component
22
+ this={listItemComponent}
23
+ {...listItemComponentProps}
24
+ {titleComponent}
25
+ {titleComponentProps}
26
+ {descriptionComponent}
27
+ {descriptionComponentProps}
28
+ {imageComponent}
29
+ {imageComponentProps}
30
+ {...item}
31
+ classes={itemClasses}
32
+ value={item}
33
+ on:click
34
+ on:clickContent
35
+ on:clickDescription
36
+ on:clickImage
37
+ on:clickTitle
38
+ />
39
+ {/each}
@@ -1,57 +1,95 @@
1
1
  <script>
2
2
  import { createEventDispatcher } from "svelte";
3
3
  const dispatch = createEventDispatcher();
4
+
5
+ import UITitle from "../various/ui.title.svelte";
4
6
  import UIButtons from "../button/ui.buttons.svelte";
5
- export let id;
7
+
6
8
  export let title;
7
9
  export let description;
8
10
  export let actions = [];
9
11
  export let classes = "";
10
12
  export let image = "";
13
+ //value of item, will be passed to event handlers
14
+ export let value;
15
+ //customization
16
+ export let titleComponent = UITitle;
17
+ export let titleComponentProps = { size: 6 };
18
+ export let descriptionComponent;
19
+ export let descriptionComponentProps = {};
20
+ export let imageComponent;
21
+ export let imageComponentProps = {};
22
+
23
+ function onClick() {
24
+ dispatch("click", value);
25
+ }
11
26
  </script>
12
27
 
13
- <div
14
- class="list-item {classes}"
15
- on:click|preventDefault={() => {
16
- dispatch("click", { id, title, image });
17
- }}
18
- >
28
+ <div class="list-item {classes}" on:click|preventDefault={onClick}>
19
29
  {#if image}
20
30
  <div
21
31
  class="list-item-image"
22
32
  on:click|preventDefault={() => {
23
- dispatch("clickImage", { id, title, image });
33
+ onClick();
34
+ dispatch("clickImage", value);
24
35
  }}
25
36
  >
26
- <figure class="image is-64x64">
27
- <img class="is-rounded" src={image} alt={title} />
28
- </figure>
37
+ {#if imageComponent}
38
+ <svelte:component
39
+ this={imageComponent}
40
+ value={image}
41
+ {...imageComponentProps}
42
+ />
43
+ {:else}
44
+ <figure class="image is-64x64">
45
+ <img class="is-rounded" src={image} alt={title} />
46
+ </figure>
47
+ {/if}
29
48
  </div>
30
49
  {/if}
31
50
  <div
32
51
  class="list-item-content"
33
52
  on:click|preventDefault={() => {
34
- dispatch("clickContent", { id, title, image });
53
+ onClick();
54
+ dispatch("clickContent", value);
35
55
  }}
36
56
  >
37
57
  {#if title}
38
58
  <div
39
59
  class="list-item-title"
40
60
  on:click|preventDefault={() => {
41
- dispatch("clickTitle", { id, title, image });
61
+ onClick();
62
+ dispatch("clickTitle", value);
42
63
  }}
43
64
  >
44
- {title}
65
+ {#if titleComponent}
66
+ <svelte:component
67
+ this={titleComponent}
68
+ {title}
69
+ {...titleComponentProps}
70
+ />
71
+ {:else}
72
+ {description}
73
+ {/if}
45
74
  </div>
46
75
  {/if}
47
76
  {#if description}
48
77
  <div
49
78
  class="list-item-description"
50
79
  on:click|preventDefault={() => {
51
- dispatch("clickDescription", { id, title, image });
80
+ onClick();
81
+ dispatch("clickDescription", value);
52
82
  }}
53
83
  >
54
- {description}
84
+ {#if descriptionComponent}
85
+ <svelte:component
86
+ this={descriptionComponent}
87
+ value={description}
88
+ {...descriptionComponentProps}
89
+ />
90
+ {:else}
91
+ {description}
92
+ {/if}
55
93
  </div>
56
94
  {/if}
57
95
  </div>
@@ -1,6 +1,8 @@
1
1
  <script>
2
2
  import UIListEmptyPlaceholder from "./ui.list.empty.placeholder.svelte";
3
3
  import UIListItem from "./ui.list.item.svelte";
4
+ import UIListBlock from "./ui.list.block.svelte";
5
+ import UITitle from "../various/ui.title.svelte";
4
6
 
5
7
  export let classes = "";
6
8
  export let items = [];
@@ -12,9 +14,21 @@
12
14
 
13
15
  export let itemClasses = "";
14
16
  export let itemLength;
15
-
17
+ export let idFieldName = "id";
18
+ //customization
19
+ //empty
16
20
  export let emptyListPlaceholderComponent = UIListEmptyPlaceholder;
17
21
  export let emptyListPlaceholderComponentProps = {};
22
+ //item
23
+ export let listItemComponent = UIListItem;
24
+ export let listItemComponentProps = {};
25
+ //item parts
26
+ export let titleComponent = UITitle;
27
+ export let titleComponentProps = { size: 6 };
28
+ export let descriptionComponent;
29
+ export let descriptionComponentProps = {};
30
+ export let imageComponent;
31
+ export let imageComponentProps = {};
18
32
  </script>
19
33
 
20
34
  {#if items.length}
@@ -28,17 +42,24 @@
28
42
  ? 'has-overflow-ellipsis'
29
43
  : ''} {hiddenImages ? 'has-hidden-images' : ''}"
30
44
  >
31
- {#each items as item (item.id)}
32
- <UIListItem
33
- {...item}
34
- classes={itemClasses}
35
- on:click
36
- on:clickContent
37
- on:clickDescription
38
- on:clickImage
39
- on:clickTitle
40
- />
41
- {/each}
45
+ <UIListBlock
46
+ bind:items
47
+ {itemClasses}
48
+ {listItemComponent}
49
+ {listItemComponentProps}
50
+ {idFieldName}
51
+ {titleComponent}
52
+ {titleComponentProps}
53
+ {descriptionComponent}
54
+ {descriptionComponentProps}
55
+ {imageComponent}
56
+ {imageComponentProps}
57
+ on:click
58
+ on:clickContent
59
+ on:clickDescription
60
+ on:clickImage
61
+ on:clickTitle
62
+ />
42
63
  </div>
43
64
  {:else}
44
65
  <svelte:component
@@ -1,11 +1,23 @@
1
- import UIBooleans from './ui.booleans.svelte';
2
- import UIIndicator from './ui.indicator.svelte';
3
- import UILoader from './ui.loader.svelte';
4
- import UIProgress from './ui.progress.svelte';
5
- import UITag from './ui.tag.svelte';
6
- import UITitle from './ui.title.svelte';
7
- import UIErrorsList from './ui.errors.list.svelte';
8
- import UIUserCard from './ui.user.card.svelte';
9
- import UISimpleSearchInput from './ui.simple.search.input.svelte';
1
+ import UIBooleans from "./ui.booleans.svelte";
2
+ import UIIndicator from "./ui.indicator.svelte";
3
+ import UILoader from "./ui.loader.svelte";
4
+ import UIProgress from "./ui.progress.svelte";
5
+ import UITag from "./ui.tag.svelte";
6
+ import UITagValue from "./ui.tag.value.svelte";
7
+ import UITitle from "./ui.title.svelte";
8
+ import UIErrorsList from "./ui.errors.list.svelte";
9
+ import UIUserCard from "./ui.user.card.svelte";
10
+ import UISimpleSearchInput from "./ui.simple.search.input.svelte";
10
11
 
11
- export { UIErrorsList, UIBooleans, UIIndicator, UILoader, UIProgress, UITag, UIUserCard, UITitle,UISimpleSearchInput };
12
+ export {
13
+ UIErrorsList,
14
+ UIBooleans,
15
+ UIIndicator,
16
+ UILoader,
17
+ UIProgress,
18
+ UITag,
19
+ UITagValue,
20
+ UIUserCard,
21
+ UITitle,
22
+ UISimpleSearchInput,
23
+ };
@@ -0,0 +1,17 @@
1
+ <script>
2
+ import UITag from "./ui.tag.svelte";
3
+
4
+ //if we want to address this tag
5
+ export let id = "taggedValueId";
6
+ export let title; //UITag props
7
+ export let value; //UITag props
8
+ </script>
9
+
10
+ <div class="tags has-addons" {id}>
11
+ {#if title}
12
+ <UITag {...title} />
13
+ {/if}
14
+ {#if value}
15
+ <UITag {...value} />
16
+ {/if}
17
+ </div>
@@ -186,7 +186,7 @@ class notSideMenu extends Menu {
186
186
  static show(e) {
187
187
  e && e.preventDefault();
188
188
  if (this.isTouch()) {
189
- this.classList.add("is-active");
189
+ this.aside.classList.add("is-active");
190
190
  } else {
191
191
  this.aside.classList.remove("is-closed");
192
192
  }
@@ -1,248 +1,279 @@
1
- import UICommon from '../../elements/common';
1
+ import UICommon from "../../elements/common";
2
2
 
3
- import notBreadcrumbs from '../components/breadcrumbs';
3
+ import notBreadcrumbs from "../components/breadcrumbs";
4
4
 
5
- import {notForm, notTable, notFormUtils} from '../components';
5
+ import { notForm, notTable, notFormUtils } from "../components";
6
6
 
7
- import notController from '../controller';
8
- import notCommon from '../common';
7
+ import notController from "../controller";
8
+ import notCommon from "../common";
9
9
 
10
- import CRUDVariantsPreloader from './variants.preloader.js';
11
- import CRUDRouter from './router.js';
12
- import CRUDMessage from './message.js';
13
- import CRUDActions from './actions';
10
+ import CRUDVariantsPreloader from "./variants.preloader.js";
11
+ import CRUDRouter from "./router.js";
12
+ import CRUDMessage from "./message.js";
13
+ import CRUDActions from "./actions";
14
14
 
15
15
  const BREADCRUMBS = [];
16
- const TITLE_FIELDS_PRIORITY = ['title', 'label', 'id', 'name'];
16
+ const TITLE_FIELDS_PRIORITY = ["title", "label", "id", "name"];
17
17
 
18
18
  class notCRUD extends notController {
19
+ #actions = { ...CRUDActions };
20
+ #router = CRUDRouter;
21
+ #preloader = CRUDVariantsPreloader;
22
+
23
+ TITLE_FIELDS_PRIORITY = TITLE_FIELDS_PRIORITY;
24
+ static ERROR_DEFAULT = UICommon.ERROR_DEFAULT;
25
+
26
+ TOP_CLASS = ["box"];
27
+ MAIN_CLASS = ["box"];
28
+ BOTTOM_CLASS = ["box"];
29
+
30
+ constructor(app, name, { actions, router, preloader } = {}) {
31
+ super(app, `CRUD.${name}`);
32
+ if (actions) {
33
+ this.#actions = { ...this.#actions, ...actions };
34
+ }
35
+ if (router) {
36
+ this.#router = router;
37
+ }
38
+ if (preloader) {
39
+ this.#preloader = preloader;
40
+ }
41
+ this.ui = {};
42
+ this.els = {};
43
+ this.setOptions("names", {
44
+ module: "",
45
+ plural: "plural",
46
+ single: "single",
47
+ });
48
+ this.setOptions(
49
+ "containerSelector",
50
+ this.app.getOptions("crud.containerSelector")
51
+ );
52
+ this.buildFrame();
53
+ return this;
54
+ }
55
+
56
+ start() {
57
+ let newHead = [];
58
+ if (this.getModuleName() && this.getOptions("names.module")) {
59
+ newHead.push({
60
+ title: this.getOptions("names.module"),
61
+ url: false,
62
+ });
63
+ }
64
+ newHead.push({
65
+ title: this.getOptions("names.plural"),
66
+ url: this.getModelURL(),
67
+ });
68
+ BREADCRUMBS.splice(0, BREADCRUMBS.length, ...newHead);
69
+ notBreadcrumbs.setHead(BREADCRUMBS).render({
70
+ root: "",
71
+ target: this.els.top,
72
+ navigate: (url) => this.app.getWorking("router").navigate(url),
73
+ });
74
+ this.route(this.getOptions("params"));
75
+ }
76
+
77
+ setBreadcrumbs(tail) {
78
+ notBreadcrumbs.setTail(tail).update();
79
+ }
80
+
81
+ backToList() {
82
+ this.app.getWorking("router").navigate(this.linkBackToList());
83
+ }
19
84
 
20
- #actions = {...CRUDActions};
21
- #router = CRUDRouter;
22
- #preloader = CRUDVariantsPreloader;
23
-
24
- TITLE_FIELDS_PRIORITY = TITLE_FIELDS_PRIORITY;
25
- static ERROR_DEFAULT = UICommon.ERROR_DEFAULT;
26
-
27
- constructor(app, name, { actions, router, preloader} = {}) {
28
- super(app, `CRUD.${name}`);
29
- if(actions){
30
- this.#actions = {...this.#actions, ...actions};
31
- }
32
- if(router){
33
- this.#router = router;
34
- }
35
- if(preloader){
36
- this.#preloader = preloader;
37
- }
38
- this.ui = {};
39
- this.els = {};
40
- this.setOptions('names', {
41
- module: '',
42
- plural: 'plural',
43
- single: 'single',
44
- });
45
- this.setOptions('containerSelector', this.app.getOptions('crud.containerSelector'));
46
- this.buildFrame();
47
- return this;
48
- }
49
-
50
- start(){
51
- let newHead = [];
52
- if(this.getModuleName() && this.getOptions('names.module')){
53
- newHead.push({
54
- title: this.getOptions('names.module'),
55
- url: false
56
- });
57
- }
58
- newHead.push({
59
- title: this.getOptions('names.plural'),
60
- url: this.getModelURL()
61
- });
62
- BREADCRUMBS.splice(0, BREADCRUMBS.length, ...newHead);
63
- notBreadcrumbs.setHead(BREADCRUMBS).render({
64
- root: '',
65
- target: this.els.top,
66
- navigate: (url) => this.app.getWorking('router').navigate(url)
67
- });
68
- this.route(this.getOptions('params'));
69
- }
70
-
71
- setBreadcrumbs(tail) {
72
- notBreadcrumbs.setTail(tail).update();
73
- }
74
-
75
- backToList() {
76
- this.app.getWorking('router').navigate(this.linkBackToList());
77
- }
78
-
79
- linkBackToList() {
80
- return this.getModelURL();
81
- }
82
-
83
- afterAction(action = 'list'){
84
- let navBack = this.app.getOptions('crud.navigateBackAfter', []);
85
- if(navBack && Array.isArray(navBack) && navBack.indexOf(action) > -1){
86
- window.history.back();
87
- }else{
88
- this.backToList();
89
- }
90
- }
91
-
92
- buildFrame() {
93
- let el = document.querySelector(this.app.getOptions('crud.containerSelector', 'body'));
94
- while (el.firstChild) {
95
- el.removeChild(el.firstChild);
96
- }
97
- this.els.top = document.createElement('div');
98
- this.els.top.id = 'crud-top';
99
- this.els.top.classList.add('box');
100
- el.appendChild(this.els.top);
101
- this.els.main = document.createElement('div');
102
- this.els.main.id = 'crud-main';
103
- this.els.main.classList.add('box');
104
- el.appendChild(this.els.main);
105
- this.els.bottom = document.createElement('div');
106
- this.els.bottom.id = 'crud-bottom';
107
- this.els.bottom.classList.add('box');
108
- el.appendChild(this.els.bottom);
109
- }
110
-
111
- getContainerTopElement(){
112
- return this.els.top;
113
- }
114
-
115
- getContainerInnerElement(){
116
- return this.els.main;
117
- }
118
-
119
- getContainerBottomElement(){
120
- return this.els.bottom;
121
- }
122
-
123
- async preloadVariants(type = 'list'){
124
- await this.#preloader.preload(this, type);
125
- }
126
-
127
- getTitleFromLib(propName, id){
128
- throw new Error('not suported anymore');
129
- //return Form.getVariant(propName, id).title;
130
- }
131
-
132
- getItemTitle(item){
133
- const fieldName = this.TITLE_FIELDS_PRIORITY.find(
134
- (key) => notCommon.objHas(item, key)
135
- );
136
- if(fieldName){
137
- return item[fieldName];
138
- }else{
139
- return '';
140
- }
141
- }
142
-
143
- createDefault() {
144
- let newRecord = this.getModel({
145
- '_id': null,
146
- title: this.getOptions('names.single'),
147
- products: []
148
- });
149
- return newRecord;
150
- }
151
-
152
- route(params = []) {
153
- try{
154
- return this.#router.route(this, params);
155
- }catch(e){
156
- this.report(e);
157
- this.showErrorMessage(e);
158
- }
159
- }
160
-
161
- runAction(actionName, params){
162
- if(Object.keys(this.#actions).includes(actionName)){
163
- return this.#actions[actionName].run(this, params)
164
- }else if(typeof this['run'+ notCommon.capitalizeFirstLetter(actionName)]){
165
- throw new Error(`No such action: ${actionName} in contoller ${this.getWorking('name')}`);
166
- }
167
- }
168
-
169
- goCreate() {
170
- this.$destroyUI();
171
- this.app.getWorking('router').navigate(this.getModelActionURL(false, 'create'));
172
- }
173
-
174
- goDetails(value) {
175
- this.$destroyUI();
176
- this.app.getWorking('router').navigate(this.getModelActionURL(value, false));
177
- }
178
-
179
- goUpdate(value) {
180
- this.$destroyUI();
181
- this.app.getWorking('router').navigate(this.getModelActionURL(value, 'update'));
182
- }
183
-
184
- goDelete(value) {
185
- this.$destroyUI();
186
- this.app.getWorking('router').navigate(this.getModelActionURL(value, 'delete'));
187
- }
188
-
189
- goList() {
190
- this.$destroyUI();
191
- this.app.getWorking('router').navigate(this.getModelURL());
192
- }
193
-
194
- async onActionSubmit(action, item){
195
- let state = true;
196
- const actionUI = this.ui[action];
197
- if(actionUI){
198
- try{
199
- actionUI.setLoading();
200
- let result = await this.getModel(item)[`$${action}`]();
201
- state = actionUI.processResult(result);
202
- }catch(e){
203
- state = actionUI.processResult(e);
204
- }finally{
205
- actionUI.resetLoading();
206
- return state;
207
- }
208
- }
209
- throw new Error('Action UI doesnt exist');
210
- }
211
-
212
- $destroyUI() {
213
- for (let name in this.ui) {
214
- this.ui[name].$destroy && this.ui[name].$destroy();
215
- this.ui[name].destroy && this.ui[name].destroy();
216
- delete this.ui[name];
217
- }
218
- }
219
-
220
- showErrorMessage(res){
221
- this.error(res);
222
- CRUDMessage.error(
223
- this,
224
- 'Произошла ошибка',
225
- res.message ? res.message : UICommon.ERROR_DEFAULT
226
- );
227
- }
228
-
229
- showSuccessMessage(title, message){
230
- CRUDMessage.success(
231
- this,
232
- title,
233
- message
234
- );
235
- }
236
-
237
- setUI(name, val){
238
- this.$destroyUI();
239
- this.ui[name] = val;
240
- }
241
-
242
- getActionUI(){
243
- return this.ui[this.getCurrentAction()];
244
- }
85
+ linkBackToList() {
86
+ return this.getModelURL();
87
+ }
88
+
89
+ afterAction(action = "list") {
90
+ let navBack = this.app.getOptions("crud.navigateBackAfter", []);
91
+ if (navBack && Array.isArray(navBack) && navBack.indexOf(action) > -1) {
92
+ window.history.back();
93
+ } else {
94
+ this.backToList();
95
+ }
96
+ }
97
+
98
+ buildFrame() {
99
+ let el = document.querySelector(
100
+ this.app.getOptions("crud.containerSelector", "body")
101
+ );
102
+ while (el.firstChild) {
103
+ el.removeChild(el.firstChild);
104
+ }
105
+ this.els.top = document.createElement("div");
106
+ this.els.top.id = "crud-top";
107
+ this.getFrameClasses().TOP_CLASS.forEach((name) =>
108
+ this.els.top.classList.add(name)
109
+ );
110
+ el.appendChild(this.els.top);
111
+ this.els.main = document.createElement("div");
112
+ this.els.main.id = "crud-main";
113
+ this.getFrameClasses().MAIN_CLASS.forEach((name) =>
114
+ this.els.main.classList.add(name)
115
+ );
116
+ el.appendChild(this.els.main);
117
+ this.els.bottom = document.createElement("div");
118
+ this.els.bottom.id = "crud-bottom";
119
+ this.getFrameClasses().BOTTOM_CLASS.forEach((name) =>
120
+ this.els.bottom.classList.add(name)
121
+ );
122
+ el.appendChild(this.els.bottom);
123
+ }
124
+
125
+ getFrameClasses() {
126
+ return {
127
+ TOP_CLASS: this.TOP_CLASS,
128
+ MAIN_CLASS: this.MAIN_CLASS,
129
+ BOTTOM_CLASS: this.BOTTOM_CLASS,
130
+ };
131
+ }
245
132
 
133
+ getContainerTopElement() {
134
+ return this.els.top;
135
+ }
136
+
137
+ getContainerInnerElement() {
138
+ return this.els.main;
139
+ }
140
+
141
+ getContainerBottomElement() {
142
+ return this.els.bottom;
143
+ }
144
+
145
+ async preloadVariants(type = "list") {
146
+ await this.#preloader.preload(this, type);
147
+ }
148
+
149
+ getTitleFromLib(propName, id) {
150
+ throw new Error("not suported anymore");
151
+ //return Form.getVariant(propName, id).title;
152
+ }
153
+
154
+ getItemTitle(item) {
155
+ const fieldName = this.TITLE_FIELDS_PRIORITY.find((key) =>
156
+ notCommon.objHas(item, key)
157
+ );
158
+ if (fieldName) {
159
+ return item[fieldName];
160
+ } else {
161
+ return "";
162
+ }
163
+ }
164
+
165
+ createDefault() {
166
+ let newRecord = this.getModel({
167
+ _id: null,
168
+ title: this.getOptions("names.single"),
169
+ products: [],
170
+ });
171
+ return newRecord;
172
+ }
173
+
174
+ route(params = []) {
175
+ try {
176
+ return this.#router.route(this, params);
177
+ } catch (e) {
178
+ this.report(e);
179
+ this.showErrorMessage(e);
180
+ }
181
+ }
182
+
183
+ runAction(actionName, params) {
184
+ if (Object.keys(this.#actions).includes(actionName)) {
185
+ return this.#actions[actionName].run(this, params);
186
+ } else if (
187
+ typeof this["run" + notCommon.capitalizeFirstLetter(actionName)]
188
+ ) {
189
+ throw new Error(
190
+ `No such action: ${actionName} in contoller ${this.getWorking(
191
+ "name"
192
+ )}`
193
+ );
194
+ }
195
+ }
196
+
197
+ goCreate() {
198
+ this.$destroyUI();
199
+ this.app
200
+ .getWorking("router")
201
+ .navigate(this.getModelActionURL(false, "create"));
202
+ }
203
+
204
+ goDetails(value) {
205
+ this.$destroyUI();
206
+ this.app
207
+ .getWorking("router")
208
+ .navigate(this.getModelActionURL(value, false));
209
+ }
210
+
211
+ goUpdate(value) {
212
+ this.$destroyUI();
213
+ this.app
214
+ .getWorking("router")
215
+ .navigate(this.getModelActionURL(value, "update"));
216
+ }
217
+
218
+ goDelete(value) {
219
+ this.$destroyUI();
220
+ this.app
221
+ .getWorking("router")
222
+ .navigate(this.getModelActionURL(value, "delete"));
223
+ }
224
+
225
+ goList() {
226
+ this.$destroyUI();
227
+ this.app.getWorking("router").navigate(this.getModelURL());
228
+ }
229
+
230
+ async onActionSubmit(action, item) {
231
+ let state = true;
232
+ const actionUI = this.ui[action];
233
+ if (actionUI) {
234
+ try {
235
+ actionUI.setLoading();
236
+ let result = await this.getModel(item)[`$${action}`]();
237
+ state = actionUI.processResult(result);
238
+ } catch (e) {
239
+ state = actionUI.processResult(e);
240
+ } finally {
241
+ actionUI.resetLoading();
242
+ return state;
243
+ }
244
+ }
245
+ throw new Error("Action UI doesnt exist");
246
+ }
247
+
248
+ $destroyUI() {
249
+ for (let name in this.ui) {
250
+ this.ui[name].$destroy && this.ui[name].$destroy();
251
+ this.ui[name].destroy && this.ui[name].destroy();
252
+ delete this.ui[name];
253
+ }
254
+ }
255
+
256
+ showErrorMessage(res) {
257
+ this.error(res);
258
+ CRUDMessage.error(
259
+ this,
260
+ "Произошла ошибка",
261
+ res.message ? res.message : UICommon.ERROR_DEFAULT
262
+ );
263
+ }
264
+
265
+ showSuccessMessage(title, message) {
266
+ CRUDMessage.success(this, title, message);
267
+ }
268
+
269
+ setUI(name, val) {
270
+ this.$destroyUI();
271
+ this.ui[name] = val;
272
+ }
273
+
274
+ getActionUI() {
275
+ return this.ui[this.getCurrentAction()];
276
+ }
246
277
  }
247
278
 
248
279
  export default notCRUD;