@eeacms/volto-clms-theme 1.0.76 → 1.0.79

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.
@@ -2,88 +2,12 @@ import './styles.less';
2
2
 
3
3
  import { CardBlockSchema, HomeUsersSchema } from './HomeUsersSchema';
4
4
  /** upload image */
5
- import { Dimmer, Image, Label, Loader, Message } from 'semantic-ui-react';
6
- import { Icon, InlineForm, SidebarPortal } from '@plone/volto/components';
5
+ import { InlineForm, SidebarPortal } from '@plone/volto/components';
7
6
  import React, { useState } from 'react';
8
- import { connect, useDispatch } from 'react-redux';
9
- import { defineMessages, useIntl } from 'react-intl';
10
7
  import { emptyCard, getPanels } from '../utils';
11
- import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers';
12
8
 
13
- import { compose } from 'redux';
14
- import { createContent } from '@plone/volto/actions';
15
- import editingSVG from '@plone/volto/icons/editing.svg';
16
9
  import { isEmpty } from 'lodash';
17
- import navSVG from '@plone/volto/icons/nav.svg';
18
- import { readAsDataURL } from 'promise-file-reader';
19
- import uploadSVG from '@plone/volto/icons/upload.svg';
20
-
21
- const messages = defineMessages({
22
- uploadImage: {
23
- id: 'Upload image',
24
- defaultMessage: 'Upload or select an image',
25
- },
26
- uploadingFile: {
27
- id: 'Uploading file',
28
- defaultMessage: 'Uploading file',
29
- },
30
- removeImage: {
31
- id: 'Remove image',
32
- defaultMessage: 'Remove image',
33
- },
34
- editImage: {
35
- id: 'Edit image',
36
- defaultMessage: 'Edit',
37
- },
38
- });
39
-
40
- function onUploadImage(pathname, e, setUploading, dispatch) {
41
- e.stopPropagation();
42
- e.preventDefault();
43
- const target = e.target;
44
- const file = target.files[0];
45
- readAsDataURL(file).then((data) => {
46
- setUploading(true);
47
- const fields = data.match(/^data:(.*);(.*),(.*)$/);
48
- dispatch(
49
- createContent(getBaseUrl(pathname), {
50
- '@type': 'Image',
51
- image: {
52
- data: fields[3],
53
- encoding: fields[2],
54
- 'content-type': fields[1],
55
- filename: file.name,
56
- },
57
- }),
58
- );
59
- });
60
- }
61
-
62
- function onChangeCardBlockImage(
63
- onChangeBlock,
64
- block,
65
- data,
66
- selectedCardBlock,
67
- imageValue,
68
- ) {
69
- onChangeBlock(block, {
70
- ...data,
71
- customCards: {
72
- ...data.customCards,
73
- blocks: {
74
- ...data.customCards.blocks,
75
- [selectedCardBlock]: {
76
- ...data.customCards.blocks[selectedCardBlock],
77
- image: imageValue,
78
- },
79
- },
80
- },
81
- });
82
- }
83
-
84
- function isSelected(selected, uid, selectedCardBlock) {
85
- return selected && uid === selectedCardBlock;
86
- }
10
+ import CclImageEditor from '@eeacms/volto-clms-theme/components/CclImageEditor/CclImageEditor';
87
11
 
88
12
  function isBlockEdit(selected, selectedCardBlock) {
89
13
  return selected && selectedCardBlock === -1;
@@ -93,107 +17,16 @@ function isCardEdit(selected, blocks, selectedCardBlock) {
93
17
  return selected && blocks && selectedCardBlock !== -1;
94
18
  }
95
19
 
96
- function handleEdit(handleEditProps) {
97
- const {
98
- selected,
99
- uid,
100
- selectedCardBlock,
101
- setSelectedCardBlock,
102
- openObjectBrowser,
103
- onChangeBlock,
104
- block,
105
- data,
106
- } = handleEditProps;
107
- if (isSelected(selected, uid, selectedCardBlock)) {
108
- openObjectBrowser({
109
- onSelectItem: (url, element) =>
110
- onChangeCardBlockImage(onChangeBlock, block, data, selectedCardBlock, {
111
- url: element['@id'],
112
- alt: element.title,
113
- }),
114
- });
115
- } else {
116
- setSelectedCardBlock(uid);
117
- }
118
- }
119
-
120
- const UploadingDimmer = ({ uid, selectedCardBlock, uploading, intl }) => {
121
- return uid === selectedCardBlock && uploading ? (
122
- <Dimmer active>
123
- <Loader indeterminate>
124
- {intl.formatMessage(messages.uploadingFile)}
125
- </Loader>
126
- </Dimmer>
127
- ) : (
128
- <></>
129
- );
130
- };
131
-
132
- const ImageEditor = ({
133
- editable,
134
- pathname,
135
- setUploading,
136
- dispatch,
137
- onChangeBlock,
138
- block,
139
- data,
140
- selectedCardBlock,
141
- openObjectBrowser,
142
- }) => {
143
- return (
144
- editable && (
145
- <p>
146
- <label className="file">
147
- <Icon className="ui button" name={uploadSVG} size={35} />
148
- <input
149
- type="file"
150
- onChange={(e) => onUploadImage(pathname, e, setUploading, dispatch)}
151
- style={{ display: 'none' }}
152
- />
153
- </label>
154
- <label className="file">
155
- <Icon className="ui button" name={navSVG} size={35} />
156
- <input
157
- type="button"
158
- onClick={(e) => {
159
- e.stopPropagation();
160
- e.preventDefault();
161
- openObjectBrowser({
162
- onSelectItem: (url, element) =>
163
- onChangeCardBlockImage(
164
- onChangeBlock,
165
- block,
166
- data,
167
- selectedCardBlock,
168
- {
169
- url: element['@id'],
170
- alt: element.title,
171
- },
172
- ),
173
- });
174
- }}
175
- style={{ display: 'none' }}
176
- />
177
- </label>
178
- </p>
179
- )
180
- );
181
- };
182
-
183
20
  const CclHomeUsersBlockEdit = ({
184
21
  block,
185
22
  data,
186
23
  onChangeBlock,
187
24
  selected,
188
25
  editable,
189
- request,
190
- content,
191
26
  setSidebarTab,
192
27
  openObjectBrowser,
193
28
  pathname,
194
29
  }) => {
195
- const intl = useIntl();
196
-
197
30
  const properties = isEmpty(data?.customCards?.blocks)
198
31
  ? emptyCard(4)
199
32
  : data.customCards;
@@ -213,27 +46,6 @@ const CclHomeUsersBlockEdit = ({
213
46
  }, []);
214
47
 
215
48
  const [selectedCardBlock, setSelectedCardBlock] = useState(-1);
216
- const [uploading, setUploading] = useState(false);
217
- const dispatch = useDispatch();
218
- React.useEffect(() => {
219
- if (!__SERVER__) {
220
- setUploading(false);
221
- }
222
- if (!selected) {
223
- setSelectedCardBlock(-1);
224
- }
225
- }, [selected]);
226
-
227
- React.useEffect(() => {
228
- if (request.loaded && !request.loading) {
229
- setUploading(false);
230
- onChangeCardBlockImage(onChangeBlock, block, data, selectedCardBlock, {
231
- url: flattenToAppURL(content['@id']),
232
- alt: content?.image?.filename,
233
- });
234
- }
235
- /* eslint-disable-next-line */
236
- }, [request]);
237
49
 
238
50
  return (
239
51
  <>
@@ -264,100 +76,19 @@ const CclHomeUsersBlockEdit = ({
264
76
  >
265
77
  <div className="card-line">
266
78
  <div className="card-image">
267
- {panel.image?.url ? (
268
- <>
269
- {isSelected(selected, uid, selectedCardBlock) && (
270
- <Label
271
- as="a"
272
- color="red"
273
- pointing="below"
274
- onClick={() =>
275
- onChangeCardBlockImage(
276
- onChangeBlock,
277
- block,
278
- data,
279
- selectedCardBlock,
280
- {},
281
- )
282
- }
283
- >
284
- {intl.formatMessage(messages.removeImage)}
285
- </Label>
286
- )}
287
-
288
- <div
289
- role="button"
290
- tabindex="0"
291
- className="ui image edit-image-container"
292
- onClick={(e) => {
293
- e.stopPropagation();
294
- e.preventDefault();
295
- const handleEditPC = {
296
- selected: selected,
297
- uid: uid,
298
- selectedCardBlock: selectedCardBlock,
299
- setSelectedCardBlock: setSelectedCardBlock,
300
- openObjectBrowser: openObjectBrowser,
301
- onChangeBlock: onChangeBlock,
302
- block: block,
303
- data: data,
304
- };
305
- handleEdit(handleEditPC);
306
- }}
307
- onKeyDown={(e) => {
308
- e.stopPropagation();
309
- e.preventDefault();
310
- const handleEditPK = {
311
- selected: selected,
312
- uid: uid,
313
- selectedCardBlock: selectedCardBlock,
314
- setSelectedCardBlock: setSelectedCardBlock,
315
- openObjectBrowser: openObjectBrowser,
316
- onChangeBlock: onChangeBlock,
317
- block: block,
318
- data: data,
319
- };
320
- handleEdit(handleEditPK);
321
- }}
322
- >
323
- <Image
324
- size="small"
325
- src={`${panel.image.url}/@@images/image`}
326
- />
327
- {isSelected(selected, uid, selectedCardBlock) && (
328
- <div className="edit-image">
329
- <Icon className="ui" name={editingSVG} size={35} />
330
- {intl.formatMessage(messages.editImage)}
331
- </div>
332
- )}
333
- </div>
334
- </>
335
- ) : (
336
- <div className="image-add">
337
- <Message className="image-message">
338
- <UploadingDimmer
339
- uid={uid}
340
- selectedCardBlock={selectedCardBlock}
341
- uploading={uploading}
342
- intl={intl}
343
- />
344
- <center>
345
- <h4>{intl.formatMessage(messages.uploadImage)}</h4>
346
- <ImageEditor
347
- editable={editable}
348
- pathname={pathname}
349
- setUploading={setUploading}
350
- dispatch={dispatch}
351
- onChangeBlock={onChangeBlock}
352
- block={block}
353
- data={data}
354
- selectedCardBlock={selectedCardBlock}
355
- openObjectBrowser={openObjectBrowser}
356
- />
357
- </center>
358
- </Message>
359
- </div>
360
- )}
79
+ <CclImageEditor
80
+ block={block}
81
+ data={data}
82
+ editable={editable}
83
+ imageUrl={panel?.image?.url}
84
+ onChangeBlock={onChangeBlock}
85
+ openObjectBrowser={openObjectBrowser}
86
+ pathname={pathname}
87
+ selected={selected}
88
+ selectedCardBlock={selectedCardBlock}
89
+ setSelectedCardBlock={setSelectedCardBlock}
90
+ uid={uid}
91
+ />
361
92
  </div>
362
93
  <div className={'card-text'}>
363
94
  <div className="card-title">{panel?.title}</div>
@@ -412,12 +143,4 @@ const CclHomeUsersBlockEdit = ({
412
143
  </>
413
144
  );
414
145
  };
415
- export default compose(
416
- connect(
417
- (state) => ({
418
- request: state.content.create,
419
- content: state.content.data,
420
- }),
421
- { createContent },
422
- ),
423
- )(CclHomeUsersBlockEdit);
146
+ export default CclHomeUsersBlockEdit;
@@ -31,8 +31,6 @@ import { ARCGIS_BLOCK } from '@eeacms/volto-arcgis-block/constants';
31
31
  import BlockSettingsSchema from '@plone/volto/components/manage/Blocks/Block/Schema';
32
32
  import CclButtonBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclButtonBlock/CclButtonBlockEdit';
33
33
  import CclButtonBlockView from '@eeacms/volto-clms-theme/components/Blocks/CclButtonBlock/CclButtonBlockView';
34
- import CclCardBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclCardBlock/CclCardBlockEdit';
35
- import CclCardBlockView from '@eeacms/volto-clms-theme/components/Blocks/CclCardBlock/CclCardBlockView';
36
34
  import CclCardContainerBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclCardContainerBlock/CclCardContainerBlockEdit';
37
35
  import CclCardContainerBlockView from '@eeacms/volto-clms-theme/components/Blocks/CclCardContainerBlock/CclCardContainerBlockView';
38
36
  import CclContextNavigationBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclContextNavigationBlock/CclContextNavigationBlockEdit';
@@ -58,7 +56,6 @@ import TextLinkCarouselEdit from '@eeacms/volto-clms-theme/components/Blocks/Ccl
58
56
  import TextLinkCarouselView from '@eeacms/volto-clms-theme/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselView';
59
57
  import SubscriptionBlockView from '@eeacms/volto-clms-theme/components/Blocks/CclSubscriptionBlock/SubscriptionView';
60
58
  import SubscriptionBlockEdit from '@eeacms/volto-clms-theme/components/Blocks/CclSubscriptionBlock/SubscriptionEdit';
61
- import cardSVG from '@plone/volto/icons/indent.svg';
62
59
  import containerSVG from '@plone/volto/icons/apps.svg';
63
60
  import customIdFieldSchema from '@eeacms/volto-clms-theme/components/Blocks/CustomTemplates/VoltoFormBlock/customIdFieldSchema';
64
61
  import downSVG from '@plone/volto/icons/down-key.svg';
@@ -83,6 +80,7 @@ function listingVariation(id, isDefault, title, template, isWO = false) {
83
80
  id: id,
84
81
  isDefault: isDefault,
85
82
  title: title,
83
+ templateID: template,
86
84
  template: isWO
87
85
  ? CclListingWorkOpportunities
88
86
  : VariationHOC(CclListingCards, template),
@@ -283,22 +281,6 @@ const customBlocks = (config) => ({
283
281
  view: [], // Future proof (not implemented yet) view user role(s)
284
282
  },
285
283
  },
286
- cardBlock: {
287
- id: 'cardBlock', // The name (id) of the block
288
- title: 'Card Block', // The display name of the block
289
- icon: cardSVG, // The icon used in the block chooser
290
- group: 'ccl_blocks', // The group (blocks can be grouped, displayed in the chooser)
291
- view: CclCardBlockView, // The view mode component
292
- edit: CclCardBlockEdit, // The edit mode component
293
- restricted: false, // If the block is restricted, it won't show in the chooser
294
- mostUsed: false, // A meta group `most used`, appearing at the top of the chooser
295
- blockHasOwnFocusManagement: false, // Set this to true if the block manages its own focus
296
- sidebarTab: 1, // The sidebar tab you want to be selected when selecting the block
297
- security: {
298
- addPermission: [], // Future proof (not implemented yet) add user permission role(s)
299
- view: [], // Future proof (not implemented yet) view user role(s)
300
- },
301
- },
302
284
  search: {
303
285
  ...config.blocks.blocksConfig.search,
304
286
  variations: [