@eeacms/volto-editing-progress 0.4.0 → 2.0.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/.eslintrc.js +65 -0
- package/CHANGELOG.md +21 -0
- package/jest-addon.config.js +19 -4
- package/jest.setup.js +65 -0
- package/locales/de/LC_MESSAGES/volto.po +3 -3
- package/locales/en/LC_MESSAGES/volto.po +3 -3
- package/locales/it/LC_MESSAGES/volto.po +3 -3
- package/locales/ro/LC_MESSAGES/volto.po +3 -3
- package/locales/volto.pot +5 -5
- package/package.json +2 -1
- package/src/VisualJSONWidget.jsx +89 -12
- package/src/VisualWidget.test.js +1459 -5
- package/src/WidgetDataComponent.jsx +97 -0
- package/src/less/editor.less +10 -1
- package/.project.eslintrc.js +0 -48
|
@@ -18,6 +18,8 @@ const EditDataComponent = ({
|
|
|
18
18
|
value,
|
|
19
19
|
fields,
|
|
20
20
|
getDropdownValues,
|
|
21
|
+
handleUpdateEnforceCharLimits,
|
|
22
|
+
handleRemoveEnforceCharLimits,
|
|
21
23
|
}) => {
|
|
22
24
|
const path = flattenToAppURL(
|
|
23
25
|
'/@vocabularies/plone.app.vocabularies.WorkflowStates',
|
|
@@ -74,6 +76,16 @@ const EditDataComponent = ({
|
|
|
74
76
|
value: makeFirstLetterCapital(state),
|
|
75
77
|
}));
|
|
76
78
|
};
|
|
79
|
+
|
|
80
|
+
// Get enforceCharLimits rule if it exists
|
|
81
|
+
const getEnforceCharLimitsRule = () => {
|
|
82
|
+
if (!currentContentType || !value[currentContentType.id]) return null;
|
|
83
|
+
return value[currentContentType.id].find(
|
|
84
|
+
(rule) => rule.type === 'enforceCharLimits',
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const enforceCharLimitsRule = getEnforceCharLimitsRule();
|
|
77
89
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
78
90
|
// const inputRef = useRef();
|
|
79
91
|
const [inputValue, setInputValue] = useState('');
|
|
@@ -129,6 +141,91 @@ const EditDataComponent = ({
|
|
|
129
141
|
}}
|
|
130
142
|
>
|
|
131
143
|
<Accordion styled fluid>
|
|
144
|
+
{/* Enforce Character Limits section */}
|
|
145
|
+
{enforceCharLimitsRule &&
|
|
146
|
+
requestStateOptions?.loaded &&
|
|
147
|
+
!requestStateOptions?.loading &&
|
|
148
|
+
requestStateOptions?.data && (
|
|
149
|
+
<React.Fragment key="enforceCharLimits">
|
|
150
|
+
<Accordion.Title
|
|
151
|
+
active={activeIndex === 'charLimits'}
|
|
152
|
+
index="charLimits"
|
|
153
|
+
onClick={() =>
|
|
154
|
+
setActiveIndex(
|
|
155
|
+
activeIndex === 'charLimits' ? -1 : 'charLimits',
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
id="property_enforceCharLimits"
|
|
159
|
+
>
|
|
160
|
+
<div className="title-editing-progress">
|
|
161
|
+
<Icon name="dropdown" size="tiny" />
|
|
162
|
+
Enforce character limits
|
|
163
|
+
</div>
|
|
164
|
+
<div className="title-editing-progress">
|
|
165
|
+
<Icon
|
|
166
|
+
name="cancel"
|
|
167
|
+
size="mini"
|
|
168
|
+
onClick={(e) => {
|
|
169
|
+
e.preventDefault();
|
|
170
|
+
e.stopPropagation();
|
|
171
|
+
handleRemoveEnforceCharLimits();
|
|
172
|
+
}}
|
|
173
|
+
/>
|
|
174
|
+
</div>
|
|
175
|
+
</Accordion.Title>
|
|
176
|
+
<Accordion.Content
|
|
177
|
+
active={activeIndex === 'charLimits'}
|
|
178
|
+
id="property_content_enforceCharLimits"
|
|
179
|
+
>
|
|
180
|
+
<label
|
|
181
|
+
htmlFor="charLimitsLinkLabel"
|
|
182
|
+
style={{ display: 'block', padding: '10px' }}
|
|
183
|
+
>
|
|
184
|
+
Link Label (use {'{title}'} as placeholder)
|
|
185
|
+
</label>
|
|
186
|
+
<input
|
|
187
|
+
className="message-input"
|
|
188
|
+
value={enforceCharLimitsRule.linkLabel || ''}
|
|
189
|
+
onChange={(e) =>
|
|
190
|
+
handleUpdateEnforceCharLimits('linkLabel', e.target.value)
|
|
191
|
+
}
|
|
192
|
+
name="charLimitsLinkLabel"
|
|
193
|
+
style={{ padding: '10px' }}
|
|
194
|
+
placeholder="Fix {title}"
|
|
195
|
+
/>
|
|
196
|
+
<label
|
|
197
|
+
htmlFor="charLimitsStates"
|
|
198
|
+
style={{ display: 'block', padding: '10px' }}
|
|
199
|
+
>
|
|
200
|
+
States
|
|
201
|
+
</label>
|
|
202
|
+
<Dropdown
|
|
203
|
+
placeholder="States"
|
|
204
|
+
multiple
|
|
205
|
+
floating
|
|
206
|
+
selection
|
|
207
|
+
search
|
|
208
|
+
name="charLimitsStates"
|
|
209
|
+
value={
|
|
210
|
+
enforceCharLimitsRule.states?.map((s) =>
|
|
211
|
+
makeFirstLetterCapital(s),
|
|
212
|
+
) || ['All']
|
|
213
|
+
}
|
|
214
|
+
options={createStateOption(
|
|
215
|
+
requestStateOptions.data.items.map(
|
|
216
|
+
(option) => option.token,
|
|
217
|
+
),
|
|
218
|
+
)}
|
|
219
|
+
onChange={(e, data) =>
|
|
220
|
+
handleUpdateEnforceCharLimits('states', data.value)
|
|
221
|
+
}
|
|
222
|
+
renderLabel={renderLabel}
|
|
223
|
+
/>
|
|
224
|
+
</Accordion.Content>
|
|
225
|
+
</React.Fragment>
|
|
226
|
+
)}
|
|
227
|
+
|
|
228
|
+
{/* Regular fields */}
|
|
132
229
|
{request?.loaded &&
|
|
133
230
|
!request?.loading &&
|
|
134
231
|
requestStateOptions?.loaded &&
|
package/src/less/editor.less
CHANGED
|
@@ -5,6 +5,15 @@
|
|
|
5
5
|
&.sidenav-ol--ep {
|
|
6
6
|
left: @progress-wf-sidebar-width;
|
|
7
7
|
padding: 1.5rem;
|
|
8
|
+
|
|
9
|
+
.ep-sidenav-li {
|
|
10
|
+
list-style: none;
|
|
11
|
+
text-align: left;
|
|
12
|
+
|
|
13
|
+
.ep-sidenav-a {
|
|
14
|
+
text-align: left;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
}
|
|
9
18
|
}
|
|
10
19
|
|
|
@@ -25,9 +34,9 @@
|
|
|
25
34
|
display: inline-block;
|
|
26
35
|
width: 10px;
|
|
27
36
|
height: 10px;
|
|
37
|
+
border-radius: 50%;
|
|
28
38
|
margin-left: 5px;
|
|
29
39
|
background-color: @orange;
|
|
30
|
-
border-radius: 50%;
|
|
31
40
|
content: '';
|
|
32
41
|
}
|
|
33
42
|
}
|
package/.project.eslintrc.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const projectRootPath = fs.existsSync('./project')
|
|
5
|
-
? fs.realpathSync('./project')
|
|
6
|
-
: fs.realpathSync('./../../../');
|
|
7
|
-
const packageJson = require(path.join(projectRootPath, 'package.json'));
|
|
8
|
-
const jsConfig = require(path.join(projectRootPath, 'jsconfig.json')).compilerOptions;
|
|
9
|
-
|
|
10
|
-
const pathsConfig = jsConfig.paths;
|
|
11
|
-
|
|
12
|
-
let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
|
|
13
|
-
|
|
14
|
-
Object.keys(pathsConfig).forEach(pkg => {
|
|
15
|
-
if (pkg === '@plone/volto') {
|
|
16
|
-
voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
|
|
20
|
-
const reg = new AddonConfigurationRegistry(projectRootPath);
|
|
21
|
-
|
|
22
|
-
// Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
|
|
23
|
-
const addonAliases = Object.keys(reg.packages).map(o => [
|
|
24
|
-
o,
|
|
25
|
-
reg.packages[o].modulePath,
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
module.exports = {
|
|
30
|
-
extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
|
|
31
|
-
settings: {
|
|
32
|
-
'import/resolver': {
|
|
33
|
-
alias: {
|
|
34
|
-
map: [
|
|
35
|
-
['@plone/volto', '@plone/volto/src'],
|
|
36
|
-
...addonAliases,
|
|
37
|
-
['@package', `${__dirname}/src`],
|
|
38
|
-
['~', `${__dirname}/src`],
|
|
39
|
-
],
|
|
40
|
-
extensions: ['.js', '.jsx', '.json'],
|
|
41
|
-
},
|
|
42
|
-
'babel-plugin-root-import': {
|
|
43
|
-
rootPathSuffix: 'src',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|