generator-folklore 3.0.6 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/lib/generators/babel/index.js +8 -1
  2. package/lib/generators/build/index.js +3 -1
  3. package/lib/generators/cli/index.js +4 -1
  4. package/lib/generators/docs/index.js +9 -4
  5. package/lib/generators/eslint/index.js +12 -1
  6. package/lib/generators/intl/index.js +3 -1
  7. package/lib/generators/laravel-mediatheque/index.js +18 -0
  8. package/lib/generators/laravel-mediatheque/instructions/ServiceProvider.php +26 -0
  9. package/lib/generators/laravel-panneau/index.js +51 -5
  10. package/lib/generators/laravel-panneau/instructions/ServiceProvider.php +21 -0
  11. package/lib/generators/laravel-panneau/instructions/config.php +13 -0
  12. package/lib/generators/laravel-panneau/templates/app/Contracts/Repositories/Pages.php +2 -2
  13. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Block.php +10 -0
  14. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Image.php +15 -0
  15. package/lib/generators/laravel-panneau/templates/app/Contracts/Resources/Blocks/Text.php +2 -0
  16. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlockResource.php +1 -1
  17. package/lib/generators/laravel-panneau/templates/app/Http/Resources/BlocksCollection.php +2 -0
  18. package/lib/generators/laravel-panneau/templates/app/Http/Resources/PageResource.php +6 -4
  19. package/lib/generators/laravel-panneau/templates/app/Models/Block.php +11 -0
  20. package/lib/generators/laravel-panneau/templates/app/Models/Media.php +11 -0
  21. package/lib/generators/laravel-panneau/templates/app/Models/Page.php +12 -2
  22. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/.gitkeep +0 -0
  23. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/BlocksCollection.php +2 -0
  24. package/lib/generators/laravel-panneau/templates/app/Panneau/Http/Resources/UsersCollection.php +10 -0
  25. package/lib/generators/laravel-panneau/templates/app/Panneau/PanneauServiceProvider.php +30 -4
  26. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/ImageBlock.php +30 -0
  27. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/TextBlock.php +3 -2
  28. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks.php +4 -1
  29. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages/Page.php +2 -2
  30. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Pages.php +2 -2
  31. package/lib/generators/laravel-panneau/templates/app/Repositories/Pages.php +2 -2
  32. package/lib/generators/laravel-panneau/templates/app/Resources/Block.php +10 -0
  33. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/ImageBlock.php +27 -0
  34. package/lib/generators/laravel-panneau/templates/app/Resources/Blocks/TextBlock.php +7 -2
  35. package/lib/generators/laravel-panneau/templates/config.php +29 -0
  36. package/lib/generators/laravel-panneau/templates/index.js +1 -1
  37. package/lib/generators/laravel-panneau/templates/lang/en/panneau.php +4 -0
  38. package/lib/generators/laravel-panneau/templates/lang/fr/panneau.php +4 -0
  39. package/lib/generators/laravel-panneau/templates/resources/assets/js/components/panneau/fields/PageSlug.jsx +68 -0
  40. package/lib/generators/laravel-project/index.js +27 -12
  41. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/CreateNewUser.php +41 -0
  42. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/ResetUserPassword.php +31 -0
  43. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserPassword.php +34 -0
  44. package/lib/generators/laravel-project/templates/laravel/app/Actions/Fortify/UpdateUserProfileInformation.php +61 -0
  45. package/lib/generators/laravel-project/templates/laravel/app/Contracts/Repositories/Users.php +17 -0
  46. package/lib/generators/laravel-project/templates/laravel/app/Models/User.php +0 -30
  47. package/lib/generators/laravel-project/templates/laravel/app/Providers/AppServiceProvider.php +90 -15
  48. package/lib/generators/laravel-project/templates/laravel/app/Repositories/Users.php +4 -3
  49. package/lib/generators/laravel-project/templates/laravel/config/app.php +3 -2
  50. package/lib/generators/laravel-project/templates/laravel/config/image.php +204 -0
  51. package/lib/generators/lerna-repository/index.js +8 -3
  52. package/lib/generators/npm-package/index.js +6 -2
  53. package/lib/generators/prettier/index.js +5 -1
  54. package/lib/generators/react-app/index.js +22 -2
  55. package/lib/generators/react-package/index.js +14 -5
  56. package/lib/generators/rollup/index.js +8 -1
  57. package/lib/generators/server/index.js +9 -2
  58. package/lib/generators/storybook/index.js +9 -1
  59. package/lib/generators/stylelint/index.js +6 -1
  60. package/lib/generators/test/index.js +10 -1
  61. package/package.json +6 -5
  62. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Block.php +0 -22
  63. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Blocks.php +0 -87
  64. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/Page.php +0 -51
  65. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlug.php +0 -34
  66. package/lib/generators/laravel-panneau/templates/app/Panneau/Fields/PageSlugLocalized.php +0 -18
  67. package/lib/generators/laravel-panneau/templates/app/Panneau/Resources/Blocks/BlockWithBlocks.php +0 -110
@@ -0,0 +1,204 @@
1
+ <?php
2
+
3
+ return [
4
+
5
+ /*
6
+ |--------------------------------------------------------------------------
7
+ | Image sizes
8
+ |--------------------------------------------------------------------------
9
+ */
10
+ 'sizes' => [
11
+ [
12
+ 'id' => 'original',
13
+ ],
14
+ [
15
+ 'id' => 'thumbnail',
16
+ 'width' => 200,
17
+ 'height' => 200,
18
+ ],
19
+ [
20
+ 'id' => 'small',
21
+ 'maxWidth' => 500,
22
+ 'maxHeight' => 500,
23
+ ],
24
+ [
25
+ 'id' => 'medium',
26
+ 'maxWidth' => 800,
27
+ 'maxHeight' => 800,
28
+ ],
29
+ [
30
+ 'id' => 'large',
31
+ 'maxWidth' => 1600,
32
+ 'maxHeight' => 1600,
33
+ ],
34
+ ],
35
+
36
+ /*
37
+ |--------------------------------------------------------------------------
38
+ | Image Filters
39
+ |--------------------------------------------------------------------------
40
+ |
41
+ | The list of filters you can use when making an image or generating an url.
42
+ | There is some built-in filters, and you can add or replace any. It is also
43
+ | possible to declare a filter with an array or a closure instead of a Filter
44
+ | Class.
45
+ |
46
+ */
47
+ 'filters' => [
48
+ 'blur' => \Folklore\Image\Filters\Blur::class,
49
+ 'colorize' => \Folklore\Image\Filters\Colorize::class,
50
+ 'gamma' => \Folklore\Image\Filters\Gamma::class,
51
+ 'grayscale' => \Folklore\Image\Filters\Grayscale::class,
52
+ 'interlace' => \Folklore\Image\Filters\Interlace::class,
53
+ 'negative' => \Folklore\Image\Filters\Negative::class,
54
+ 'rotate' => \Folklore\Image\Filters\Rotate::class,
55
+ 'resize' => \Folklore\Image\Filters\Resize::class
56
+ ],
57
+
58
+ /*
59
+ |--------------------------------------------------------------------------
60
+ | Default Source
61
+ |--------------------------------------------------------------------------
62
+ |
63
+ | This option define the default source to be used by the Image facade. The
64
+ | source determine where the image files are read and saved.
65
+ |
66
+ */
67
+ 'source' => 'public',
68
+
69
+ /*
70
+ |--------------------------------------------------------------------------
71
+ | Sources
72
+ |--------------------------------------------------------------------------
73
+ |
74
+ | The list of sources where you store images.
75
+ |
76
+ | Supported driver: "local", "filesystem"
77
+ |
78
+ */
79
+ 'sources' => [
80
+
81
+ 'public' => [
82
+ // The local driver use a local path on the machine.
83
+ 'driver' => 'local',
84
+
85
+ // The path where the images are stored.
86
+ 'path' => public_path()
87
+ ],
88
+
89
+ 'cloud' => [
90
+ // The filesystem driver lets you use the filesystem from laravel.
91
+ 'driver' => 'filesystem',
92
+
93
+ // The filesystem disk where the images are stored.
94
+ 'disk' => 'public',
95
+
96
+ // The path on the disk where the images are stored. If set to null,
97
+ // it will start from the root.
98
+ 'path' => null,
99
+
100
+ // Cache the file on local machine. It can be useful for remote files.
101
+ 'cache' => true,
102
+
103
+ // The path where you want to put cached files
104
+ 'cache_path' => storage_path('image/cache')
105
+ ]
106
+
107
+ ],
108
+
109
+ /*
110
+ |--------------------------------------------------------------------------
111
+ | URL Generator
112
+ |--------------------------------------------------------------------------
113
+ |
114
+ | The URL Generator configuration is used when generating an image url
115
+ | and by the router to generate a pattern for catching image requests.
116
+ | These are the defaults values and you can overide it in each routes or
117
+ | when generating an url using the `pattern` parameter.
118
+ |
119
+ */
120
+ 'url' => [
121
+ // The format of the url that will be generated. The `{filters}` placeholder
122
+ // will be replaced by the filters according to the `filters_format`.
123
+ 'format' => '{dirname}/{basename}{filters}.{extension}',
124
+
125
+ // The format of the filters that will replace `{filters}` in the
126
+ // url `format` above. The `{filter}` placeholder will be replaced by
127
+ // each filter according to the `filter_format` and joined
128
+ // by the `filter_separator`.
129
+ 'filters_format' => '-filters({filter})',
130
+
131
+ // The format of a filter.
132
+ 'filter_format' => '{key}({value})',
133
+
134
+ // The separator for each filter
135
+ 'filter_separator' => '-',
136
+
137
+ // This is the regex that will replace any placeholders in the option 'format'.
138
+ // They are used when the route pattern is generated and added to the
139
+ // Laravel Router to match image request.
140
+ 'placeholders_patterns' => [
141
+ 'host' => '(.*?)?',
142
+ 'dirname' => '(.*?)?',
143
+ 'basename' => '([^\/\.]+?)',
144
+ 'filename' => '([^\/]+)',
145
+ 'extension' => '(jpeg|jpg|gif|png)',
146
+ ]
147
+ ],
148
+
149
+ /*
150
+ |--------------------------------------------------------------------------
151
+ | Routes
152
+ |--------------------------------------------------------------------------
153
+ |
154
+ | Default configuration for image routes. See routes/image.php
155
+ |
156
+ */
157
+ 'routes' => [
158
+ // Path to the routes file that will be automatically loaded. Set to null
159
+ // to prevent auto-loading of routes.
160
+ 'map' => base_path('routes/images.php'),
161
+
162
+ // Default domain for routes
163
+ 'domain' => null,
164
+
165
+ // Default namespace for controller
166
+ 'namespace' => null,
167
+
168
+ // Default middlewares for routes
169
+ 'middleware' => [],
170
+
171
+ // The controller serving the images
172
+ 'controller' => '\Folklore\Image\Http\ImageController@serve',
173
+
174
+ // The name of the pattern that will be added to the Laravel Router.
175
+ 'pattern_name' => 'image_pattern',
176
+
177
+ // The middleware used when a route as `cache` enabled
178
+ 'cache_middleware' => 'image.middleware.cache'
179
+ ],
180
+
181
+ /*
182
+ |--------------------------------------------------------------------------
183
+ | Image Driver
184
+ |--------------------------------------------------------------------------
185
+ |
186
+ | This option controls the default image "driver" used by Imagine library
187
+ | to manipulate images.
188
+ |
189
+ | Supported: "gd", "imagick", "gmagick"
190
+ |
191
+ */
192
+ 'driver' => 'gd',
193
+
194
+ /*
195
+ |--------------------------------------------------------------------------
196
+ | Memory limit
197
+ |--------------------------------------------------------------------------
198
+ |
199
+ | When manipulating an image, the memory limit is increased to this value
200
+ |
201
+ */
202
+ 'memory_limit' => '128M',
203
+
204
+ ];
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _chalk = _interopRequireDefault(require("chalk"));
4
+
3
5
  var _lodash = _interopRequireDefault(require("lodash"));
4
6
 
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
7
- var _chalk = _interopRequireDefault(require("chalk"));
8
-
9
9
  var _generator = _interopRequireDefault(require("../../lib/generator"));
10
10
 
11
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -217,7 +217,12 @@ module.exports = class LernaRepositoryGenerator extends _generator.default {
217
217
  return;
218
218
  }
219
219
 
220
- this.addDevDependencies(['lerna@latest', 'glob@latest', 'mkdirp@latest', '@babel/runtime@latest']);
220
+ this.addDevDependencies({
221
+ lerna: 'latest',
222
+ glob: 'latest',
223
+ mkdirp: 'latest',
224
+ '@babel/runtime': 'latest'
225
+ });
221
226
  },
222
227
 
223
228
  bootstrap() {
@@ -240,8 +240,12 @@ module.exports = class NpmPackageGenerator extends _generator.default {
240
240
  return;
241
241
  }
242
242
 
243
- this.addDependencies(['@babel/runtime@latest']);
244
- this.addDevDependencies(['jest@latest']);
243
+ this.addDependencies({
244
+ '@babel/runtime': 'latest'
245
+ });
246
+ this.addDevDependencies({
247
+ jest: 'latest'
248
+ });
245
249
  }
246
250
 
247
251
  };
@@ -31,7 +31,11 @@ module.exports = class PrettierGenerator extends _generator.default {
31
31
  },
32
32
 
33
33
  dependencies() {
34
- this.addDevDependencies(['prettier', '@prettier/plugin-php', '@trivago/prettier-plugin-sort-imports']);
34
+ this.addDevDependencies({
35
+ prettier: 'latest',
36
+ '@prettier/plugin-php': 'latest',
37
+ '@trivago/prettier-plugin-sort-imports': 'latest'
38
+ });
35
39
  }
36
40
 
37
41
  };
@@ -108,8 +108,28 @@ module.exports = class ReactAppGenerator extends _generator.default {
108
108
  },
109
109
 
110
110
  dependencies() {
111
- this.addDependencies(['react', 'react-dom', 'prop-types', 'react-intl', 'react-router', 'react-router-dom', 'react-helmet', 'classnames', '@folklore/routes', '@folklore/fonts', '@folklore/forms', '@folklore/fetch', '@folklore/hooks', '@folklore/tracking', // Polyfills
112
- 'intl', '@formatjs/intl-locale', '@formatjs/intl-pluralrules', 'intersection-observer', 'resize-observer-polyfill']);
111
+ this.addDependencies({
112
+ react: '^18.0.0',
113
+ 'react-dom': '^18.0.0',
114
+ 'prop-types': '^15.0.0',
115
+ 'react-intl': '^6.0.0',
116
+ 'react-router': '^6.0.0',
117
+ 'react-router-dom': '^6.0.0',
118
+ 'react-helmet': '^6.0.0',
119
+ classnames: 'latest',
120
+ '@folklore/routes': '^0.1.1',
121
+ '@folklore/fonts': '^0.0.11',
122
+ '@folklore/forms': '^0.0.19',
123
+ '@folklore/fetch': '^0.1.15',
124
+ '@folklore/hooks': '^0.0.27',
125
+ '@folklore/tracking': '^0.0.14',
126
+ // Polyfills
127
+ intl: 'latest',
128
+ '@formatjs/intl-locale': 'latest',
129
+ '@formatjs/intl-pluralrules': 'latest',
130
+ 'intersection-observer': 'latest',
131
+ 'resize-observer-polyfill': 'latest'
132
+ });
113
133
  }
114
134
 
115
135
  };
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _lodash = _interopRequireDefault(require("lodash"));
4
-
5
- var _path = _interopRequireDefault(require("path"));
6
-
7
3
  var _chalk = _interopRequireDefault(require("chalk"));
8
4
 
9
5
  var _changeCase = require("change-case");
10
6
 
7
+ var _lodash = _interopRequireDefault(require("lodash"));
8
+
9
+ var _path = _interopRequireDefault(require("path"));
10
+
11
11
  var _generator = _interopRequireDefault(require("../../lib/generator"));
12
12
 
13
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -192,7 +192,16 @@ module.exports = class ReactPackageGenerator extends _generator.default {
192
192
  return;
193
193
  }
194
194
 
195
- this.addDevDependencies(['domready@latest', 'jquery@latest', 'enzyme@latest', 'react-test-renderer@latest', '@storybook/react@latest', '@storybook/addon-actions@latest', 'extract-text-webpack-plugin@latest', 'html-webpack-plugin@latest']);
195
+ this.addDevDependencies({
196
+ domready: 'latest',
197
+ jquery: 'latest',
198
+ enzyme: 'latest',
199
+ 'react-test-renderer': 'latest',
200
+ '@storybook/react': 'latest',
201
+ '@storybook/addon-actions': 'latest',
202
+ 'extract-text-webpack-plugin': 'latest',
203
+ 'html-webpack-plugin': 'latest'
204
+ });
196
205
  }
197
206
 
198
207
  };
@@ -37,7 +37,14 @@ module.exports = class RollupGenerator extends _generator.default {
37
37
  },
38
38
 
39
39
  dependencies() {
40
- this.addDevDependencies(['@rollup/plugin-babel', '@rollup/plugin-commonjs', '@rollup/plugin-json', '@rollup/plugin-node-resolve', '@rollup/plugin-replace', 'rollup']);
40
+ this.addDevDependencies({
41
+ '@rollup/plugin-babel': 'latest',
42
+ '@rollup/plugin-commonjs': 'latest',
43
+ '@rollup/plugin-json': 'latest',
44
+ '@rollup/plugin-node-resolve': 'latest',
45
+ '@rollup/plugin-replace': 'latest',
46
+ rollup: '^2.79.1'
47
+ });
41
48
  }
42
49
 
43
50
  };
@@ -60,10 +60,17 @@ module.exports = class ServerGenerator extends _generator.default {
60
60
  const {
61
61
  'socket-io': socketIo
62
62
  } = this.options;
63
- this.addDependencies(['commander', 'debug', 'ejs', 'express']);
63
+ this.addDependencies({
64
+ commander: 'latest',
65
+ debug: 'latest',
66
+ ejs: 'latest',
67
+ express: 'latest'
68
+ });
64
69
 
65
70
  if (socketIo) {
66
- this.addDependencies(['socket.io']);
71
+ this.addDependencies({
72
+ 'socket.io': 'latest'
73
+ });
67
74
  }
68
75
  }
69
76
 
@@ -79,7 +79,15 @@ module.exports = class StorybookGenerator extends _generator.default {
79
79
  return;
80
80
  }
81
81
 
82
- this.addDevDependencies(['@storybook/addon-actions@latest', '@storybook/addon-info@latest', '@storybook/addon-storyshots@latest', '@storybook/addons@latest', '@storybook/react@latest', '@storybook/storybook-deployer@latest', 'glob-loader@latest']);
82
+ this.addDevDependencies({
83
+ '@storybook/addon-actions': 'latest',
84
+ '@storybook/addon-info': 'latest',
85
+ '@storybook/addon-storyshots': 'latest',
86
+ '@storybook/addons': 'latest',
87
+ '@storybook/react': 'latest',
88
+ '@storybook/storybook-deployer': 'latest',
89
+ 'glob-loader': 'latest'
90
+ });
83
91
  }
84
92
 
85
93
  };
@@ -37,7 +37,12 @@ module.exports = class StylelintGenerator extends _generator.default {
37
37
  },
38
38
 
39
39
  dependencies() {
40
- this.addDevDependencies(['stylelint', 'stylelint-config-standard-scss', 'stylelint-config-idiomatic-order', 'stylelint-config-prettier']);
40
+ this.addDevDependencies({
41
+ stylelint: '^14.0.0',
42
+ 'stylelint-config-standard-scss': 'latest',
43
+ 'stylelint-config-idiomatic-order': 'latest',
44
+ 'stylelint-config-prettier': 'latest'
45
+ });
41
46
  }
42
47
 
43
48
  };
@@ -67,7 +67,16 @@ module.exports = class TestGenerator extends _generator.default {
67
67
  return;
68
68
  }
69
69
 
70
- this.addDevDependencies(['babel-jest@latest', 'enzyme@latest', 'enzyme-adapter-react-16@latest', 'eslint-plugin-jest@latest', 'jest@latest', 'jsdom@latest', 'react-test-renderer@latest', 'sinon@latest']);
70
+ this.addDevDependencies({
71
+ 'babel-jest': 'latest',
72
+ enzyme: 'latest',
73
+ 'enzyme-adapter-react-16': 'latest',
74
+ 'eslint-plugin-jest': 'latest',
75
+ jest: 'latest',
76
+ jsdom: 'latest',
77
+ 'react-test-renderer': 'latest',
78
+ sinon: 'latest'
79
+ });
71
80
  }
72
81
 
73
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-folklore",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "Yeoman generator for projects at Folklore",
5
5
  "keywords": [
6
6
  "yeoman-generator"
@@ -9,9 +9,9 @@
9
9
  "scripts": {
10
10
  "clean:lib": "rm -rf lib/*",
11
11
  "clean": "npm run clean:lib",
12
- "copy:templates": "find src/ -type d | grep -i /templates$ | sed 's/src\\/\\///g' | xargs -I{} cp -r \"src/{}\" \"lib/{}\"",
12
+ "copy:dirs": "find src/ -type d | grep -E '(/templates|/instructions)$' | sed 's/src\\/\\///g' | xargs -I{} cp -r \"src/{}\" \"lib/{}\"",
13
13
  "compile": "../../node_modules/.bin/babel -d lib/ src/",
14
- "build": "npm run compile && npm run copy:templates",
14
+ "build": "npm run compile && npm run copy:dirs",
15
15
  "test": "echo \"Error: no test specified\" && exit 1",
16
16
  "prepare": "npm run clean && npm run build"
17
17
  },
@@ -31,13 +31,14 @@
31
31
  "dependencies": {
32
32
  "chalk": "^4.0.0",
33
33
  "change-case": "^4.1.2",
34
+ "cli-highlight": "^2.1.11",
34
35
  "glob": "^7.2.0",
35
36
  "immutable": "^4.0.0",
36
37
  "is-utf8": "^0.2.1",
37
38
  "lodash": "^4.17.21",
38
39
  "password-generator": "^2.3.2",
39
- "yeoman-generator": "^5.6.1",
40
+ "yeoman-generator": "^5.7.0",
40
41
  "yeoman-remote": "^1.0.1"
41
42
  },
42
- "gitHead": "8331a20ddf7647db4895648efb495ce23d070fb3"
43
+ "gitHead": "a8406b4ff188934ed49c13826cf577968669ed4e"
43
44
  }
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- namespace App\Panneau\Fields;
4
-
5
- use Panneau\Fields\ResourceItem;
6
-
7
- class Block extends ResourceItem
8
- {
9
- public function resource(): string
10
- {
11
- return 'blocks';
12
- }
13
-
14
- public function attributes(): ?array
15
- {
16
- return array_merge(parent::attributes(), [
17
- 'placeholder' => trans('panneau.fields.blocks_placeholder'),
18
- 'itemLabelPath' => 'title',
19
- 'itemDescriptionPath' => null,
20
- ]);
21
- }
22
- }
@@ -1,87 +0,0 @@
1
- <?php
2
-
3
- namespace App\Panneau\Fields;
4
-
5
- use Panneau\Fields\Items;
6
- use Panneau\Fields\ResourceItem;
7
- use App\Panneau\Resources\Blocks\BlockWithBlocks;
8
-
9
- class Blocks extends Items
10
- {
11
- protected $currentDepth = 0;
12
-
13
- protected $maxDepth = null;
14
-
15
- protected $excludeTypes = [];
16
-
17
- public function itemField(): ?string
18
- {
19
- return Block::class;
20
- }
21
-
22
- public function attributes(): ?array
23
- {
24
- // With types
25
- $itemField = $this->itemField();
26
- $itemField = !is_null($itemField) ? resolve($itemField) : null;
27
- $itemResource =
28
- !is_null($itemField) && $itemField instanceof ResourceItem
29
- ? $itemField->makeResource()
30
- : null;
31
- $resourceTypes =
32
- !is_null($itemResource) && $itemResource->hasTypes() ? $itemResource->getTypes() : null;
33
-
34
- $attributes = [
35
- 'withoutFormGroup' => true,
36
- 'addItemLabel' => trans('panneau.fields.add_block'),
37
- 'noItemLabel' => trans('panneau.fields.no_blocks'),
38
- 'itemLabel' => trans('panneau.fields.block'),
39
- 'withoutSort' => false,
40
- ];
41
-
42
- if (!is_null($resourceTypes)) {
43
- $attributes['types'] = $resourceTypes
44
- ->filter(function ($type) {
45
- $key = get_class($type);
46
- return !in_array($key, $this->excludeTypes);
47
- })
48
- ->map(function ($type) {
49
- $hasBlocks = collect($type->fields())->contains(function ($field) {
50
- return $field instanceof self;
51
- });
52
- if (isset($this->maxDepth) && $hasBlocks) {
53
- return new BlockWithBlocks($type, $this->currentDepth + 1);
54
- }
55
- return $type;
56
- })
57
- ->filter(function ($type) {
58
- if (isset($this->maxDepth) && $type instanceof BlockWithBlocks) {
59
- return $type->currentDepth() < $this->maxDepth;
60
- }
61
- return true;
62
- })
63
- ->values()
64
- ->toArray();
65
- }
66
-
67
- return $attributes;
68
- }
69
-
70
- public function maxDepth($depth)
71
- {
72
- $this->maxDepth = $depth;
73
- return $this;
74
- }
75
-
76
- public function currentDepth($depth)
77
- {
78
- $this->currentDepth = $depth;
79
- return $this;
80
- }
81
-
82
- public function withoutType($type)
83
- {
84
- $this->excludeTypes[] = is_object($type) ? get_class($type) : $type;
85
- return $this;
86
- }
87
- }
@@ -1,51 +0,0 @@
1
- <?php
2
-
3
- namespace App\Panneau\Fields;
4
-
5
- use Panneau\Fields\ResourceItem;
6
-
7
- class Page extends ResourceItem
8
- {
9
- protected $query = [
10
- 'paginated' => false,
11
- ];
12
-
13
- protected $pageTypes = [];
14
-
15
- public function resource(): string
16
- {
17
- return 'pages';
18
- }
19
-
20
- public function component(): string
21
- {
22
- return 'item';
23
- }
24
-
25
- public function attributes(): ?array
26
- {
27
- $query = $this->query;
28
- if (isset($this->pageTypes) && sizeof($this->pageTypes) > 0) {
29
- $query['type'] = $this->pageTypes;
30
- }
31
-
32
- return array_merge(parent::attributes(), [
33
- 'placeholder' => trans('panneau.forms.page_placeholder'),
34
- 'itemLabelPath' => 'title.'.app()->getLocale(),
35
- 'itemImagePath' => null,
36
- 'requestQuery' => $query,
37
- ]);
38
- }
39
-
40
- public function withQuery($query)
41
- {
42
- $this->query = $query;
43
- return $this;
44
- }
45
-
46
- public function withTypes($types)
47
- {
48
- $this->pageTypes = is_array($types) ? $types : func_get_args();
49
- return $this;
50
- }
51
- }
@@ -1,34 +0,0 @@
1
- <?php
2
-
3
- namespace App\Panneau\Fields;
4
-
5
- use Panneau\Fields\Text;
6
-
7
- class PageSlug extends Text
8
- {
9
- public function component(): string
10
- {
11
- return 'page-slug';
12
- }
13
-
14
- public function attributes(): ?array
15
- {
16
- $locale = app()->getLocale();
17
- $locales = config('locale.locales');
18
- $finalLocale = in_array($this->name, $locales) ? $this->name : $locale;
19
-
20
- return array_merge(parent::attributes(), [
21
- 'routes' => [
22
- 'page' => url()->routeForReactRouter($finalLocale . '.page', [
23
- 'withoutPatterns' => true,
24
- ]),
25
- 'page_with_parent' => url()->routeForReactRouter(
26
- $finalLocale . '.page_with_parent',
27
- [
28
- 'withoutPatterns' => true,
29
- ]
30
- ),
31
- ],
32
- ]);
33
- }
34
- }
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- namespace App\Panneau\Fields;
4
-
5
- use Panneau\Support\LocalizedField;
6
-
7
- class PageSlugLocalized extends LocalizedField
8
- {
9
- public function component(): string
10
- {
11
- return 'page-slug-localized';
12
- }
13
-
14
- public function field($locale)
15
- {
16
- return new PageSlug($locale);
17
- }
18
- }