@smartsoft001/crud-shell-angular 1.2.91 → 2.69.0
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/.storybook/addons.js +1 -0
- package/.storybook/config.js +5 -0
- package/.storybook/tsconfig.json +8 -0
- package/.storybook/webpack.config.js +7 -0
- package/jest.config.ts +38 -0
- package/ng-package.json +7 -0
- package/package.json +12 -23
- package/project.json +49 -0
- package/src/index.ts +13 -0
- package/src/lib/+state/crud.facade.ts +82 -0
- package/src/lib/+state/crud.feature.methods.ts +258 -0
- package/src/lib/+state/crud.feature.store.ts +77 -0
- package/src/lib/components/components.module.ts +58 -0
- package/src/lib/components/export/export.component.ts +69 -0
- package/src/lib/components/filter/base/base.component.ts +175 -0
- package/src/lib/components/filter/check/check.component.scss +25 -0
- package/src/lib/components/filter/check/check.component.ts +72 -0
- package/src/lib/components/filter/date/date.component.html +30 -0
- package/src/lib/components/filter/date/date.component.ts +70 -0
- package/src/lib/components/filter/date-time/date-time.component.html +62 -0
- package/src/lib/components/filter/date-time/date-time.component.ts +56 -0
- package/src/lib/components/filter/date-with-edit/date-with-edit.component.html +109 -0
- package/src/lib/components/filter/date-with-edit/date-with-edit.component.ts +70 -0
- package/src/lib/components/filter/filter.component.html +52 -0
- package/src/lib/components/filter/filter.component.ts +34 -0
- package/src/lib/components/filter/flag/flag.component.ts +55 -0
- package/src/lib/components/filter/index.ts +9 -0
- package/src/lib/components/filter/int/int.component.html +74 -0
- package/src/lib/components/filter/int/int.component.ts +57 -0
- package/src/lib/components/filter/radio/radio.component.ts +74 -0
- package/src/lib/components/filter/text/text.component.ts +46 -0
- package/src/lib/components/filters/filters.component.scss +150 -0
- package/src/lib/components/filters/filters.component.ts +157 -0
- package/src/lib/components/filters-config/filters-config.component.ts +69 -0
- package/src/lib/components/group/group.component.ts +93 -0
- package/src/lib/components/index.ts +7 -0
- package/src/lib/components/multiselect/multiselect.component.html +41 -0
- package/src/lib/components/multiselect/multiselect.component.scss +125 -0
- package/src/lib/components/multiselect/multiselect.component.ts +104 -0
- package/src/lib/crud-full.module.ts +51 -0
- package/src/lib/crud.config.ts +79 -0
- package/src/lib/crud.module.ts +72 -0
- package/src/lib/factories/list-pagination/list-pagination.factory.ts +77 -0
- package/src/lib/models/index.ts +1 -0
- package/src/lib/models/interfaces.ts +34 -0
- package/src/lib/pages/index.ts +6 -0
- package/src/lib/pages/item/base/base.component.ts +54 -0
- package/src/lib/pages/item/item.component.ts +513 -0
- package/src/lib/pages/item/standard/standard.component.scss +0 -0
- package/src/lib/pages/item/standard/standard.component.ts +50 -0
- package/src/lib/pages/list/base/base.component.ts +29 -0
- package/src/lib/pages/list/list.component.stories.ts +77 -0
- package/src/lib/pages/list/list.component.ts +438 -0
- package/src/lib/pages/list/standard/standard.component.ts +42 -0
- package/src/lib/pipes/form-options/form-options.pipe.ts +61 -0
- package/src/lib/pipes/index.ts +2 -0
- package/src/lib/pipes/pipes.module.ts +9 -0
- package/src/lib/providers/model-possibilities/model-possibilities.provider.ts +19 -0
- package/src/lib/services/crud/crud.service.spec.ts +303 -0
- package/src/lib/services/crud/crud.service.ts +178 -0
- package/src/lib/services/list-group/list-group.service.spec.ts +87 -0
- package/src/lib/services/list-group/list-group.service.ts +65 -0
- package/src/lib/services/page/page.service.spec.ts +143 -0
- package/src/lib/services/page/page.service.ts +44 -0
- package/src/lib/services/search/search.service.spec.ts +134 -0
- package/src/lib/services/search/search.service.ts +42 -0
- package/test-setup.ts +0 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +31 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +10 -0
- package/tslint.json +10 -0
- package/esm2022/index.mjs +0 -18
- package/esm2022/lib/+state/crud.actions.mjs +0 -224
- package/esm2022/lib/+state/crud.effects.mjs +0 -182
- package/esm2022/lib/+state/crud.facade.mjs +0 -91
- package/esm2022/lib/+state/crud.reducer.mjs +0 -214
- package/esm2022/lib/+state/crud.selectors.mjs +0 -11
- package/esm2022/lib/components/components.module.mjs +0 -110
- package/esm2022/lib/components/export/export.component.mjs +0 -47
- package/esm2022/lib/components/filter/base/base.component.mjs +0 -152
- package/esm2022/lib/components/filter/check/check.component.mjs +0 -36
- package/esm2022/lib/components/filter/date/date.component.mjs +0 -47
- package/esm2022/lib/components/filter/date-time/date-time.component.mjs +0 -43
- package/esm2022/lib/components/filter/date-with-edit/date-with-edit.component.mjs +0 -49
- package/esm2022/lib/components/filter/filter.component.mjs +0 -30
- package/esm2022/lib/components/filter/flag/flag.component.mjs +0 -16
- package/esm2022/lib/components/filter/index.mjs +0 -10
- package/esm2022/lib/components/filter/int/int.component.mjs +0 -38
- package/esm2022/lib/components/filter/radio/radio.component.mjs +0 -16
- package/esm2022/lib/components/filter/text/text.component.mjs +0 -16
- package/esm2022/lib/components/filters/filters.component.mjs +0 -111
- package/esm2022/lib/components/filters-config/filters-config.component.mjs +0 -37
- package/esm2022/lib/components/group/group.component.mjs +0 -54
- package/esm2022/lib/components/index.mjs +0 -8
- package/esm2022/lib/components/multiselect/multiselect.component.mjs +0 -71
- package/esm2022/lib/crud-full.module.mjs +0 -103
- package/esm2022/lib/crud.config.mjs +0 -17
- package/esm2022/lib/crud.module.mjs +0 -106
- package/esm2022/lib/factories/list-pagination/list-pagination.factory.mjs +0 -69
- package/esm2022/lib/models/index.mjs +0 -2
- package/esm2022/lib/models/interfaces.mjs +0 -2
- package/esm2022/lib/pages/index.mjs +0 -7
- package/esm2022/lib/pages/item/base/base.component.mjs +0 -44
- package/esm2022/lib/pages/item/item.component.mjs +0 -395
- package/esm2022/lib/pages/item/standard/standard.component.mjs +0 -15
- package/esm2022/lib/pages/list/base/base.component.mjs +0 -23
- package/esm2022/lib/pages/list/list.component.mjs +0 -355
- package/esm2022/lib/pages/list/standard/standard.component.mjs +0 -34
- package/esm2022/lib/pipes/form-options/form-options.pipe.mjs +0 -55
- package/esm2022/lib/pipes/index.mjs +0 -3
- package/esm2022/lib/pipes/pipes.module.mjs +0 -20
- package/esm2022/lib/providers/model-possibilities/model-possibilities.provider.mjs +0 -11
- package/esm2022/lib/services/crud/crud.service.mjs +0 -138
- package/esm2022/lib/services/list-group/list-group.service.mjs +0 -60
- package/esm2022/lib/services/page/page.service.mjs +0 -41
- package/esm2022/lib/services/search/search.service.mjs +0 -41
- package/esm2022/lib/services/socket/socket.service.mjs +0 -17
- package/esm2022/smartsoft001-crud-shell-angular.mjs +0 -5
- package/fesm2022/smartsoft001-crud-shell-angular.mjs +0 -2810
- package/fesm2022/smartsoft001-crud-shell-angular.mjs.map +0 -1
- package/index.d.ts +0 -18
- package/index.d.ts.map +0 -1
- package/lib/+state/crud.actions.d.ts +0 -152
- package/lib/+state/crud.actions.d.ts.map +0 -1
- package/lib/+state/crud.effects.d.ts +0 -18
- package/lib/+state/crud.effects.d.ts.map +0 -1
- package/lib/+state/crud.facade.d.ts +0 -44
- package/lib/+state/crud.facade.d.ts.map +0 -1
- package/lib/+state/crud.reducer.d.ts +0 -43
- package/lib/+state/crud.reducer.d.ts.map +0 -1
- package/lib/+state/crud.selectors.d.ts +0 -10
- package/lib/+state/crud.selectors.d.ts.map +0 -1
- package/lib/components/components.module.d.ts +0 -27
- package/lib/components/components.module.d.ts.map +0 -1
- package/lib/components/export/export.component.d.ts +0 -21
- package/lib/components/export/export.component.d.ts.map +0 -1
- package/lib/components/filter/base/base.component.d.ts +0 -39
- package/lib/components/filter/base/base.component.d.ts.map +0 -1
- package/lib/components/filter/check/check.component.d.ts +0 -19
- package/lib/components/filter/check/check.component.d.ts.map +0 -1
- package/lib/components/filter/date/date.component.d.ts +0 -16
- package/lib/components/filter/date/date.component.d.ts.map +0 -1
- package/lib/components/filter/date-time/date-time.component.d.ts +0 -15
- package/lib/components/filter/date-time/date-time.component.d.ts.map +0 -1
- package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts +0 -17
- package/lib/components/filter/date-with-edit/date-with-edit.component.d.ts.map +0 -1
- package/lib/components/filter/filter.component.d.ts +0 -14
- package/lib/components/filter/filter.component.d.ts.map +0 -1
- package/lib/components/filter/flag/flag.component.d.ts +0 -8
- package/lib/components/filter/flag/flag.component.d.ts.map +0 -1
- package/lib/components/filter/index.d.ts +0 -10
- package/lib/components/filter/index.d.ts.map +0 -1
- package/lib/components/filter/int/int.component.d.ts +0 -15
- package/lib/components/filter/int/int.component.d.ts.map +0 -1
- package/lib/components/filter/radio/radio.component.d.ts +0 -8
- package/lib/components/filter/radio/radio.component.d.ts.map +0 -1
- package/lib/components/filter/text/text.component.d.ts +0 -8
- package/lib/components/filter/text/text.component.d.ts.map +0 -1
- package/lib/components/filters/filters.component.d.ts +0 -83
- package/lib/components/filters/filters.component.d.ts.map +0 -1
- package/lib/components/filters-config/filters-config.component.d.ts +0 -19
- package/lib/components/filters-config/filters-config.component.d.ts.map +0 -1
- package/lib/components/group/group.component.d.ts +0 -23
- package/lib/components/group/group.component.d.ts.map +0 -1
- package/lib/components/index.d.ts +0 -8
- package/lib/components/index.d.ts.map +0 -1
- package/lib/components/multiselect/multiselect.component.d.ts +0 -28
- package/lib/components/multiselect/multiselect.component.d.ts.map +0 -1
- package/lib/crud-full.module.d.ts +0 -28
- package/lib/crud-full.module.d.ts.map +0 -1
- package/lib/crud.config.d.ts +0 -65
- package/lib/crud.config.d.ts.map +0 -1
- package/lib/crud.module.d.ts +0 -34
- package/lib/crud.module.d.ts.map +0 -1
- package/lib/factories/list-pagination/list-pagination.factory.d.ts +0 -20
- package/lib/factories/list-pagination/list-pagination.factory.d.ts.map +0 -1
- package/lib/models/index.d.ts +0 -2
- package/lib/models/index.d.ts.map +0 -1
- package/lib/models/interfaces.d.ts +0 -30
- package/lib/models/interfaces.d.ts.map +0 -1
- package/lib/pages/index.d.ts +0 -7
- package/lib/pages/index.d.ts.map +0 -1
- package/lib/pages/item/base/base.component.d.ts +0 -25
- package/lib/pages/item/base/base.component.d.ts.map +0 -1
- package/lib/pages/item/item.component.d.ts +0 -70
- package/lib/pages/item/item.component.d.ts.map +0 -1
- package/lib/pages/item/standard/standard.component.d.ts +0 -8
- package/lib/pages/item/standard/standard.component.d.ts.map +0 -1
- package/lib/pages/list/base/base.component.d.ts +0 -15
- package/lib/pages/list/base/base.component.d.ts.map +0 -1
- package/lib/pages/list/list.component.d.ts +0 -54
- package/lib/pages/list/list.component.d.ts.map +0 -1
- package/lib/pages/list/standard/standard.component.d.ts +0 -14
- package/lib/pages/list/standard/standard.component.d.ts.map +0 -1
- package/lib/pipes/form-options/form-options.pipe.d.ts +0 -15
- package/lib/pipes/form-options/form-options.pipe.d.ts.map +0 -1
- package/lib/pipes/index.d.ts +0 -3
- package/lib/pipes/index.d.ts.map +0 -1
- package/lib/pipes/pipes.module.d.ts +0 -8
- package/lib/pipes/pipes.module.d.ts.map +0 -1
- package/lib/providers/model-possibilities/model-possibilities.provider.d.ts +0 -18
- package/lib/providers/model-possibilities/model-possibilities.provider.d.ts.map +0 -1
- package/lib/services/crud/crud.service.d.ts +0 -38
- package/lib/services/crud/crud.service.d.ts.map +0 -1
- package/lib/services/list-group/list-group.service.d.ts +0 -15
- package/lib/services/list-group/list-group.service.d.ts.map +0 -1
- package/lib/services/page/page.service.d.ts +0 -12
- package/lib/services/page/page.service.d.ts.map +0 -1
- package/lib/services/search/search.service.d.ts +0 -16
- package/lib/services/search/search.service.d.ts.map +0 -1
- package/lib/services/socket/socket.service.d.ts +0 -10
- package/lib/services/socket/socket.service.d.ts.map +0 -1
- package/smartsoft001-crud-shell-angular.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../../../../.storybook/addons';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const rootWebpackConfig = require('../../../../../.storybook/webpack.config');
|
|
2
|
+
// Export a function. Accept the base config as the only param.
|
|
3
|
+
module.exports = async ({ config, mode }) => {
|
|
4
|
+
config = await rootWebpackConfig({ config, mode });
|
|
5
|
+
|
|
6
|
+
return config;
|
|
7
|
+
};
|
package/jest.config.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Config } from 'jest';
|
|
2
|
+
|
|
3
|
+
const config: Config = {
|
|
4
|
+
globals: {},
|
|
5
|
+
setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.(ts|js|mjs|html)$': [
|
|
8
|
+
'jest-preset-angular',
|
|
9
|
+
{
|
|
10
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
11
|
+
stringifyContentPathRegex: '\\.(html|svg)$',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
snapshotSerializers: [
|
|
16
|
+
'jest-preset-angular/build/serializers/no-ng-attributes',
|
|
17
|
+
'jest-preset-angular/build/serializers/ng-snapshot',
|
|
18
|
+
'jest-preset-angular/build/serializers/html-comment',
|
|
19
|
+
],
|
|
20
|
+
displayName: 'crud-shell-angular',
|
|
21
|
+
coverageDirectory: '../../../../coverage/packages/crud/shell/angular',
|
|
22
|
+
preset: 'jest-preset-angular',
|
|
23
|
+
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'],
|
|
24
|
+
transformIgnorePatterns: ['node_modules/(?!(@angular|@ngrx)/)'],
|
|
25
|
+
snapshotFormat: { escapeString: true, printBasicPrototype: true },
|
|
26
|
+
moduleNameMapper: {
|
|
27
|
+
'^@smartsoft001/angular$':
|
|
28
|
+
'<rootDir>/../../../../packages/shared/angular/src/index.ts',
|
|
29
|
+
'^@smartsoft001/angular/(.*)$':
|
|
30
|
+
'<rootDir>/../../../../packages/shared/angular/src/$1',
|
|
31
|
+
'^@smartsoft001/models$':
|
|
32
|
+
'<rootDir>/../../../../packages/shared/models/src/index.ts',
|
|
33
|
+
'^@smartsoft001/models/(.*)$':
|
|
34
|
+
'<rootDir>/../../../../packages/shared/models/src/$1',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default config;
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartsoft001/crud-shell-angular",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.69.0",
|
|
4
|
+
"description": "Utils and Angular components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/emiljuchnikowski/smartsoft.git"
|
|
8
8
|
},
|
|
9
9
|
"author": "Emil Juchnikowski",
|
|
10
|
+
"contributors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Andrii Bilych"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
10
15
|
"license": "ISC",
|
|
11
16
|
"bugs": {
|
|
12
17
|
"url": "https://github.com/emiljuchnikowski/smartsoft/issues"
|
|
13
18
|
},
|
|
14
19
|
"homepage": "https://github.com/emiljuchnikowski/smartsoft#readme",
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
".": {
|
|
22
|
-
"types": "./index.d.ts",
|
|
23
|
-
"esm2022": "./esm2022/smartsoft001-crud-shell-angular.mjs",
|
|
24
|
-
"esm": "./esm2022/smartsoft001-crud-shell-angular.mjs",
|
|
25
|
-
"default": "./fesm2022/smartsoft001-crud-shell-angular.mjs"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"sideEffects": false,
|
|
29
|
-
"dependencies": {
|
|
30
|
-
"tslib": "^2.3.0",
|
|
31
|
-
"@ngrx/store": "16.0.1",
|
|
32
|
-
"@smartsoft001/domain-core": "1.1.91",
|
|
33
|
-
"@smartsoft001/angular": "1.2.91"
|
|
34
|
-
},
|
|
35
|
-
"peerDependencies": {}
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@smartsoft001/angular": "^2.69.0",
|
|
22
|
+
"@angular/common": "^16.0.0",
|
|
23
|
+
"@angular/core": "^16.0.0"
|
|
24
|
+
}
|
|
36
25
|
}
|
package/project.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "crud-shell-angular",
|
|
3
|
+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"projectType": "library",
|
|
5
|
+
"sourceRoot": "packages/crud/shell/angular/src",
|
|
6
|
+
"prefix": "smart",
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint": {
|
|
9
|
+
"executor": "@nx/eslint:lint",
|
|
10
|
+
"outputs": ["{options.outputFile}"],
|
|
11
|
+
"options": {
|
|
12
|
+
"lintFilePatterns": [
|
|
13
|
+
"packages/crud/shell/angular/**/*.{ts,tsx,js,jsx}",
|
|
14
|
+
"packages/crud/shell/angular/package.json"
|
|
15
|
+
],
|
|
16
|
+
"tsConfig": [
|
|
17
|
+
"packages/crud/shell/angular/tsconfig.lib.json",
|
|
18
|
+
"packages/crud/shell/angular/tsconfig.spec.json"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"test": {
|
|
23
|
+
"executor": "@nx/jest:jest",
|
|
24
|
+
"options": {
|
|
25
|
+
"jestConfig": "packages/crud/shell/angular/jest.config.ts",
|
|
26
|
+
"passWithNoTests": true
|
|
27
|
+
},
|
|
28
|
+
"outputs": ["{workspaceRoot}/coverage/packages/crud/shell/angular"]
|
|
29
|
+
},
|
|
30
|
+
"build": {
|
|
31
|
+
"executor": "@nx/angular:package",
|
|
32
|
+
"options": {
|
|
33
|
+
"tsConfig": "packages/crud/shell/angular/tsconfig.lib.json",
|
|
34
|
+
"project": "packages/crud/shell/angular/ng-package.json"
|
|
35
|
+
},
|
|
36
|
+
"configurations": {
|
|
37
|
+
"production": {
|
|
38
|
+
"tsConfig": "packages/crud/shell/angular/tsconfig.lib.prod.json"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"generators": {
|
|
44
|
+
"@schematics/angular:component": {
|
|
45
|
+
"style": "scss"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"tags": ["scope:crud", "type:shell"]
|
|
49
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './lib/components';
|
|
2
|
+
export * from './lib/crud.config';
|
|
3
|
+
export * from './lib/crud.module';
|
|
4
|
+
export * from './lib/crud-full.module';
|
|
5
|
+
export * from './lib/factories/list-pagination/list-pagination.factory';
|
|
6
|
+
export * from './lib/pipes';
|
|
7
|
+
export * from './lib/services/crud/crud.service';
|
|
8
|
+
export * from './lib/services/page/page.service';
|
|
9
|
+
export * from './lib/services/search/search.service';
|
|
10
|
+
export * from './lib/+state/crud.facade';
|
|
11
|
+
export * from './lib/models';
|
|
12
|
+
export * from './lib/pages';
|
|
13
|
+
export * from './lib/providers/model-possibilities/model-possibilities.provider';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { computed, Injectable, Signal } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
4
|
+
|
|
5
|
+
import { CrudConfig } from '../crud.config';
|
|
6
|
+
import { ICrudCreateManyOptions, ICrudFilter } from '../models';
|
|
7
|
+
import { createCrudFeatureStore } from './crud.feature.store';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class CrudFacade<T extends IEntity<string>> {
|
|
11
|
+
private store = createCrudFeatureStore<T>();
|
|
12
|
+
|
|
13
|
+
loaded: Signal<boolean> = this.store.getLoaded;
|
|
14
|
+
loading: Signal<boolean> = computed(() => !this.store.getLoaded());
|
|
15
|
+
selected: Signal<T> = this.store.getSelected;
|
|
16
|
+
multiSelected: Signal<T[]> = this.store.getMultiSelected;
|
|
17
|
+
list: Signal<T[]> = this.store.getList;
|
|
18
|
+
filter: Signal<ICrudFilter> = this.store.getFilter;
|
|
19
|
+
totalCount: Signal<number> = this.store.getTotalCount;
|
|
20
|
+
links: Signal<any> = this.store.getLinks;
|
|
21
|
+
error: Signal<any> = this.store.getError;
|
|
22
|
+
|
|
23
|
+
constructor(private config: CrudConfig<T>) {}
|
|
24
|
+
|
|
25
|
+
create(item: T): void {
|
|
26
|
+
this.store.create(item);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createMany(items: Array<T>, options: ICrudCreateManyOptions): void {
|
|
30
|
+
this.store.createMany({ items, options });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
read(filter: ICrudFilter = null): void {
|
|
34
|
+
let baseQuery = [];
|
|
35
|
+
if (this.config.baseQuery) {
|
|
36
|
+
baseQuery = this.config.baseQuery;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const fullFilter = {
|
|
40
|
+
...(filter ? filter : {}),
|
|
41
|
+
query: filter && filter.query ? filter.query : baseQuery,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
this.store.read(fullFilter);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
clear(): void {
|
|
48
|
+
this.store.clear();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
select(id: string): void {
|
|
52
|
+
this.store.select(id);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
unselect(): void {
|
|
56
|
+
this.store.unselect();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
multiSelect(items: Array<T>): void {
|
|
60
|
+
this.store.multiSelect(items);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
update(item: T): void {
|
|
64
|
+
this.store.update(item);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export(filter: ICrudFilter = null, format = null): void {
|
|
68
|
+
this.store.export(filter, format);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
updatePartial(item: Partial<T> & { id: string }): void {
|
|
72
|
+
this.store.updatePartial(item);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
updatePartialMany(items: (Partial<T> & { id: string })[]) {
|
|
76
|
+
this.store.updatePartialMany(items);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
delete(id: string): void {
|
|
80
|
+
this.store.delete(id);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { inject } from '@angular/core';
|
|
2
|
+
import { patchState } from '@ngrx/signals';
|
|
3
|
+
|
|
4
|
+
import { PaginationMode } from '@smartsoft001/angular';
|
|
5
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
6
|
+
|
|
7
|
+
import { ICrudCreateManyOptions, ICrudFilter } from '../models';
|
|
8
|
+
import { initialState } from './crud.feature.store';
|
|
9
|
+
import { CrudService } from '../services/crud/crud.service';
|
|
10
|
+
|
|
11
|
+
// "Actions, Reducers, Effects" in a normal store
|
|
12
|
+
export function CrudMethodsFactory<T extends IEntity<string>>() {
|
|
13
|
+
return (store: any, crudService = inject(CrudService<T>)) => {
|
|
14
|
+
const methods = {
|
|
15
|
+
async create(item: T) {
|
|
16
|
+
patchState(store, {
|
|
17
|
+
loaded: false,
|
|
18
|
+
error: null,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
await crudService.create(item);
|
|
23
|
+
await this.createSuccess();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
methods.defaultFailure(error);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async createSuccess() {
|
|
30
|
+
patchState(store, {
|
|
31
|
+
loaded: true,
|
|
32
|
+
error: null,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
await methods.read(
|
|
36
|
+
store.filter ? { ...store.filter, offset: 0 } : null,
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
async createMany(data: { items: T[]; options: ICrudCreateManyOptions }) {
|
|
41
|
+
patchState(store, {
|
|
42
|
+
loaded: false,
|
|
43
|
+
error: null,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
await crudService.createMany(data.items, data.options);
|
|
48
|
+
await methods.createManySuccess();
|
|
49
|
+
} catch (e) {
|
|
50
|
+
methods.defaultFailure(e);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
async createManySuccess() {
|
|
55
|
+
patchState(store, {
|
|
56
|
+
loaded: true,
|
|
57
|
+
error: null,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
await methods.read(
|
|
61
|
+
store.filter ? { ...store.filter, offset: 0 } : null,
|
|
62
|
+
);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
async export(filter: ICrudFilter, format: any) {
|
|
66
|
+
patchState(store, {
|
|
67
|
+
loaded: false,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await crudService.exportList(filter, format);
|
|
72
|
+
methods.exportSuccess();
|
|
73
|
+
} catch (e) {
|
|
74
|
+
methods.defaultFailure(e);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
exportSuccess() {
|
|
79
|
+
patchState(store, {
|
|
80
|
+
loaded: true,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
async read(filter: ICrudFilter) {
|
|
85
|
+
patchState(store, {
|
|
86
|
+
loaded: false,
|
|
87
|
+
filter,
|
|
88
|
+
error: null,
|
|
89
|
+
totalCount: null,
|
|
90
|
+
links: null,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
try {
|
|
94
|
+
const result = await crudService.getList<T>(filter);
|
|
95
|
+
methods.readSuccess<T>({
|
|
96
|
+
list: result.data,
|
|
97
|
+
filter,
|
|
98
|
+
totalCount: result.totalCount,
|
|
99
|
+
links: result.links,
|
|
100
|
+
});
|
|
101
|
+
} catch (error) {
|
|
102
|
+
methods.defaultFailure(error);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
readSuccess<T>(data: {
|
|
107
|
+
list: T[];
|
|
108
|
+
filter?: ICrudFilter;
|
|
109
|
+
totalCount?: number;
|
|
110
|
+
links?: any;
|
|
111
|
+
}) {
|
|
112
|
+
let list = [];
|
|
113
|
+
|
|
114
|
+
if (
|
|
115
|
+
data.filter?.offset &&
|
|
116
|
+
store.list() &&
|
|
117
|
+
data.filter.paginationMode !== PaginationMode.singlePage
|
|
118
|
+
) {
|
|
119
|
+
list = [...store.list(), ...data.list];
|
|
120
|
+
} else {
|
|
121
|
+
list = data.list;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
patchState(store, {
|
|
125
|
+
loaded: true,
|
|
126
|
+
list,
|
|
127
|
+
totalCount: data.totalCount,
|
|
128
|
+
links: data.links,
|
|
129
|
+
error: null,
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
clear() {
|
|
134
|
+
store.set(() => ({ ...initialState }));
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
async select(id: string) {
|
|
138
|
+
patchState(store, {
|
|
139
|
+
loaded: false,
|
|
140
|
+
selected: null,
|
|
141
|
+
error: null,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
const result = await crudService.getById(id);
|
|
146
|
+
methods.selectSuccess(result);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
methods.defaultFailure(e);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
selectSuccess(selected: T) {
|
|
153
|
+
patchState(store, {
|
|
154
|
+
loaded: true,
|
|
155
|
+
selected,
|
|
156
|
+
error: null,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
unselect() {
|
|
161
|
+
patchState(store, {
|
|
162
|
+
loaded: true,
|
|
163
|
+
selected: null,
|
|
164
|
+
error: null,
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
multiSelect(items: Array<T>) {
|
|
169
|
+
patchState(store, {
|
|
170
|
+
multiSelected: [...items],
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
async update(item: Partial<T> & { id: string }) {
|
|
175
|
+
patchState(store, {
|
|
176
|
+
loaded: false,
|
|
177
|
+
error: null,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
await crudService.updatePartial(item);
|
|
182
|
+
await methods.updateSuccess(item.id);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
methods.defaultFailure(e);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
async updateSuccess(id: string) {
|
|
189
|
+
await methods.read({ ...store.filter, offset: 0 });
|
|
190
|
+
await methods.select(id);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
async updatePartial(item: Partial<T> & { id: string }) {
|
|
194
|
+
patchState(store, {
|
|
195
|
+
loaded: false,
|
|
196
|
+
error: null,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
await crudService.updatePartial(item);
|
|
201
|
+
await methods.updatePartialSuccess(item.id);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
methods.defaultFailure(e);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
async updatePartialSuccess(id: string) {
|
|
208
|
+
await methods.read({ ...store.filter, offset: 0 });
|
|
209
|
+
await methods.select(id);
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
async updatePartialMany(items: Array<Partial<T> & { id: string }>) {
|
|
213
|
+
patchState(store, {
|
|
214
|
+
loaded: false,
|
|
215
|
+
error: null,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
await crudService.updatePartialMany(items);
|
|
220
|
+
await methods.updatePartialManySuccess();
|
|
221
|
+
} catch (e) {
|
|
222
|
+
methods.defaultFailure(e);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
async updatePartialManySuccess() {
|
|
227
|
+
await methods.read({ ...store.filter, offset: 0 });
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
async delete(id: string) {
|
|
231
|
+
patchState(store, {
|
|
232
|
+
loaded: false,
|
|
233
|
+
error: null,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
await crudService.delete(id);
|
|
238
|
+
await methods.deleteSuccess();
|
|
239
|
+
} catch (e) {
|
|
240
|
+
methods.defaultFailure(e);
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
async deleteSuccess() {
|
|
245
|
+
await methods.read({ ...store.filter, offset: 0 });
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
defaultFailure(error: string) {
|
|
249
|
+
patchState(store, {
|
|
250
|
+
loaded: true,
|
|
251
|
+
error,
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return methods;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { computed, Signal } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
signalStore,
|
|
4
|
+
withState,
|
|
5
|
+
withMethods,
|
|
6
|
+
withComputed,
|
|
7
|
+
} from '@ngrx/signals';
|
|
8
|
+
|
|
9
|
+
import { IEntity } from '@smartsoft001/domain-core';
|
|
10
|
+
|
|
11
|
+
import { ICrudCreateManyOptions, ICrudFilter } from '../models';
|
|
12
|
+
import { CrudMethodsFactory } from './crud.feature.methods';
|
|
13
|
+
|
|
14
|
+
export interface CrudState<T> {
|
|
15
|
+
selected?: T;
|
|
16
|
+
multiSelected?: Array<T>;
|
|
17
|
+
list?: T[];
|
|
18
|
+
totalCount?: number;
|
|
19
|
+
filter?: ICrudFilter;
|
|
20
|
+
links?: any;
|
|
21
|
+
loaded: boolean; // has the Auth list been loaded
|
|
22
|
+
error?: string | null; // last none error (if any)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const initialState: CrudState<any> = {
|
|
26
|
+
loaded: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
interface CrudStore<T> extends CrudState<T> {
|
|
30
|
+
// State properties are inherited from CrudState
|
|
31
|
+
|
|
32
|
+
// Computed properties
|
|
33
|
+
getError: Signal<string | null | undefined>;
|
|
34
|
+
getLoaded: Signal<boolean>;
|
|
35
|
+
getSelected: Signal<T | undefined>;
|
|
36
|
+
getMultiSelected: Signal<Array<T> | undefined>;
|
|
37
|
+
getList: Signal<Array<T> | undefined>;
|
|
38
|
+
getTotalCount: Signal<number | undefined>;
|
|
39
|
+
getLinks: Signal<any>;
|
|
40
|
+
getFilter: Signal<ICrudFilter | undefined>;
|
|
41
|
+
|
|
42
|
+
// Methods
|
|
43
|
+
create(item: T): void;
|
|
44
|
+
createMany(data: { items: T[]; options: ICrudCreateManyOptions }): void;
|
|
45
|
+
export(filter: ICrudFilter, format: any): void;
|
|
46
|
+
read(filter: ICrudFilter): void;
|
|
47
|
+
clear(): void;
|
|
48
|
+
select(id: string): void;
|
|
49
|
+
multiSelect(items: Array<T>): void;
|
|
50
|
+
unselect(): void;
|
|
51
|
+
update(item: Partial<T> & { id: string }): void;
|
|
52
|
+
updatePartial(item: Partial<T> & { id: string }): void;
|
|
53
|
+
updatePartialMany(items: Array<Partial<T> & { id: string }>): void;
|
|
54
|
+
delete(id: string): void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function createCrudFeatureStore<T extends IEntity<string>>() {
|
|
58
|
+
return signalStore(
|
|
59
|
+
{ providedIn: 'root' },
|
|
60
|
+
withState<CrudState<T>>(initialState),
|
|
61
|
+
withComputed((store) => ({
|
|
62
|
+
getError: computed(() => store.error()),
|
|
63
|
+
getLoaded: computed(() => store.loaded()),
|
|
64
|
+
getSelected: computed(() => store.selected()),
|
|
65
|
+
getMultiSelected: computed(() => store.multiSelected()),
|
|
66
|
+
getList: computed(() => store.list()),
|
|
67
|
+
getTotalCount: computed(() => store.totalCount()),
|
|
68
|
+
getLinks: computed(() => store.links()),
|
|
69
|
+
getFilter: computed(() => store.filter()),
|
|
70
|
+
})),
|
|
71
|
+
withMethods(CrudMethodsFactory<T>()),
|
|
72
|
+
) as unknown as CrudStore<T>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type CrudFeatureStore<T extends IEntity<string>> = ReturnType<
|
|
76
|
+
typeof createCrudFeatureStore<T>
|
|
77
|
+
>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { FormsModule } from '@angular/forms';
|
|
4
|
+
import { DynamicIoModule } from 'ng-dynamic-component';
|
|
5
|
+
|
|
6
|
+
import { SharedModule } from '@smartsoft001/angular';
|
|
7
|
+
|
|
8
|
+
import { ExportComponent } from './export/export.component';
|
|
9
|
+
import {
|
|
10
|
+
FilterComponent,
|
|
11
|
+
FilterDateComponent,
|
|
12
|
+
FilterDateWithEditComponent,
|
|
13
|
+
FilterFlagComponent,
|
|
14
|
+
FilterRadioComponent,
|
|
15
|
+
FilterTextComponent,
|
|
16
|
+
FilterCheckComponent,
|
|
17
|
+
FilterIntComponent,
|
|
18
|
+
FilterDateTimeComponent,
|
|
19
|
+
} from './filter';
|
|
20
|
+
import { CrudPipesModule } from '../pipes';
|
|
21
|
+
import { FiltersComponent } from './filters/filters.component';
|
|
22
|
+
import { FiltersConfigComponent } from './filters-config/filters-config.component';
|
|
23
|
+
import { MultiselectComponent } from './multiselect/multiselect.component';
|
|
24
|
+
import { CrudFacade } from '../+state/crud.facade';
|
|
25
|
+
import { GroupComponent } from './group/group.component';
|
|
26
|
+
import { CrudListPaginationFactory } from '../factories/list-pagination/list-pagination.factory';
|
|
27
|
+
import { CrudService } from '../services/crud/crud.service';
|
|
28
|
+
|
|
29
|
+
const COMPONENTS = [
|
|
30
|
+
ExportComponent,
|
|
31
|
+
FilterComponent,
|
|
32
|
+
FilterTextComponent,
|
|
33
|
+
FiltersConfigComponent,
|
|
34
|
+
FilterDateComponent,
|
|
35
|
+
FilterDateWithEditComponent,
|
|
36
|
+
FilterDateTimeComponent,
|
|
37
|
+
FilterRadioComponent,
|
|
38
|
+
FiltersComponent,
|
|
39
|
+
FilterFlagComponent,
|
|
40
|
+
FilterCheckComponent,
|
|
41
|
+
FilterIntComponent,
|
|
42
|
+
MultiselectComponent,
|
|
43
|
+
GroupComponent,
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
@NgModule({
|
|
47
|
+
imports: [
|
|
48
|
+
...COMPONENTS,
|
|
49
|
+
SharedModule,
|
|
50
|
+
CrudPipesModule,
|
|
51
|
+
FormsModule,
|
|
52
|
+
CommonModule,
|
|
53
|
+
DynamicIoModule,
|
|
54
|
+
],
|
|
55
|
+
exports: [CrudPipesModule, ...COMPONENTS],
|
|
56
|
+
providers: [CrudService, CrudFacade, CrudListPaginationFactory],
|
|
57
|
+
})
|
|
58
|
+
export class CrudComponentsModule {}
|