@aj-shadow/z-abs-complayer-modaldialog-client 0.0.0-aj-beta.221
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/.gitattributes +26 -0
- package/LICENSE.txt +96 -0
- package/README.md +5 -0
- package/npm-shrinkwrap.json +13 -0
- package/package.json +10 -0
- package/project/client/_build/Bundle-CompLayer-Modaldialog-client.bld +38 -0
- package/project/client/_build/Client-CompLayer-Modaldialog-client-jsx.bld +10 -0
- package/project/client/_build/Client-CompLayer-Modaldialog-client.bld +10 -0
- package/project/client/_build/Client-css-CompLayer-Modaldialog-bundle.bld +9 -0
- package/project/client/_build/z-abs-complayer-modaldialog-client.prj +36 -0
- package/project/client/actions/action-modal-dialog.js +29 -0
- package/project/client/css/abstraction_add.css +10 -0
- package/project/client/css/modal-dialog-file.css +5 -0
- package/project/client/css/modal.css +162 -0
- package/project/client/css/modal_body.css +18 -0
- package/project/client/css/modal_header.css +11 -0
- package/project/client/helper/helper-event-listener.js +29 -0
- package/project/client/helper/helper-modal-popover.js +35 -0
- package/project/client/helper/input-analyzer.js +47 -0
- package/project/client/images/actor-image.jsx +260 -0
- package/project/client/images/file-image.jsx +44 -0
- package/project/client/images/msg-image.jsx +31 -0
- package/project/client/modal-dialog-abstraction-add.jsx +992 -0
- package/project/client/modal-dialog-abstraction-properties.jsx +220 -0
- package/project/client/modal-dialog-file-add.jsx +183 -0
- package/project/client/modal-dialog-file-new.jsx +489 -0
- package/project/client/modal-dialog-file-properties.jsx +206 -0
- package/project/client/modal-dialog-file-remove.jsx +157 -0
- package/project/client/modal-dialog-folder-add.jsx +292 -0
- package/project/client/modal-dialog-folder-new.jsx +231 -0
- package/project/client/modal-dialog-folder-properties.jsx +237 -0
- package/project/client/modal-dialog-folder-remove.jsx +149 -0
- package/project/client/modal-dialog-search.jsx +144 -0
- package/project/client/modal-dialog-wizard-list.jsx +49 -0
- package/project/client/modal-dialog-wizard.jsx +145 -0
- package/project/client/modal-dialog-workspace-new.jsx +157 -0
- package/project/client/modal-dialog-workspace-open.jsx +306 -0
- package/project/client/stores/modal-dialog-store.js +63 -0
- package/project/z-abs-complayer-modaldialog-client.tree +41 -0
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import HelperEventListener from './helper/helper-event-listener';
|
|
5
|
+
import HelperModalPopover from './helper/helper-modal-popover';
|
|
6
|
+
import InputAnalyzer from './helper/input-analyzer';
|
|
7
|
+
import Modal from 'z-abs-complayer-bootstrap-client/client/modal';
|
|
8
|
+
import ModalHeader from 'z-abs-complayer-bootstrap-client/client/modal-header';
|
|
9
|
+
import ModalBody from 'z-abs-complayer-bootstrap-client/client/modal-body';
|
|
10
|
+
import ModalFooter from 'z-abs-complayer-bootstrap-client/client/modal-footer';
|
|
11
|
+
import Popover from 'z-abs-complayer-bootstrap-client/client/popover';
|
|
12
|
+
import ComponentDocument from 'z-abs-complayer-markup-client/client/react-components/markup/component-document';
|
|
13
|
+
import MarkupDocumentationPage from 'z-abs-complayer-markup-client/client/markup/markup-documentation/markup-documentation-page';
|
|
14
|
+
import ReactComponentBase from 'z-abs-corelayer-client/client/react-component/react-component-base';
|
|
15
|
+
import React from 'react';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default class ModalDialogFileNew extends ReactComponentBase {
|
|
19
|
+
constructor(props) {
|
|
20
|
+
super(props, {
|
|
21
|
+
fileName: '',
|
|
22
|
+
fileType: '',
|
|
23
|
+
template: null,
|
|
24
|
+
dynamicTemplateName: '',
|
|
25
|
+
dynamicTemplateNames: [],
|
|
26
|
+
dynamicTemplateHeading: '',
|
|
27
|
+
dynamicTemplate2Index: -1,
|
|
28
|
+
dynamicTemplate2Names: [],
|
|
29
|
+
dynamicTemplate2MarkupNodes: [],
|
|
30
|
+
dynamicTemplate2MarkupStyles: [],
|
|
31
|
+
dynamicTemplate2Markups: [],
|
|
32
|
+
dynamicTemplate2Heading: '',
|
|
33
|
+
valid: false,
|
|
34
|
+
error: false,
|
|
35
|
+
errorText: ''
|
|
36
|
+
});
|
|
37
|
+
this.helperModalPopover = new HelperModalPopover();
|
|
38
|
+
this.inputRef = React.createRef();
|
|
39
|
+
this.inputAnalyzer = new InputAnalyzer(this.props.capitalFirst ? true : false);
|
|
40
|
+
this.eventListener = new HelperEventListener('keydown', this._keyDown.bind(this), true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
static getDerivedStateFromProps(props, state) {
|
|
44
|
+
let fileType = null;
|
|
45
|
+
if(props.folder) {
|
|
46
|
+
for(let i = 0; i < props.folder.data.types.length; ++i) {
|
|
47
|
+
if('actorjs' !== props.folder.data.types[i]) {
|
|
48
|
+
fileType = props.folder.data.types[i];
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const template = state.template ? state.template : (props?.templateNames && props.templateNames.length >= 1) ? props.templateNames[0] : '';
|
|
54
|
+
let dynamicTemplateNames = [];
|
|
55
|
+
let dynamicTemplateHeading = '';
|
|
56
|
+
if(props.onTemplate) {
|
|
57
|
+
const dynamicTemplate = props.onTemplate(template.name);
|
|
58
|
+
if(dynamicTemplate) {
|
|
59
|
+
dynamicTemplateNames = dynamicTemplate.names;
|
|
60
|
+
dynamicTemplateHeading = dynamicTemplate.heading;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
fileType: fileType,
|
|
66
|
+
template: template,
|
|
67
|
+
dynamicTemplateNames: dynamicTemplateNames,
|
|
68
|
+
dynamicTemplateHeading: dynamicTemplateHeading
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
didMount() {
|
|
73
|
+
this.helperModalPopover.didMount();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
shouldUpdate(nextProps, nextState) {
|
|
77
|
+
return !this.shallowCompare(this.props.heading, nextProps.heading)
|
|
78
|
+
|| !this.shallowCompare(this.props.modalResults, nextProps.modalResults)
|
|
79
|
+
|| !this.shallowCompare(this.props.templateNames, nextProps.templateNames)
|
|
80
|
+
|| !this.shallowCompare(this.state, nextState);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
didUpdate(prevProps, prevState) {
|
|
84
|
+
const previousModalResult = prevProps.modalResults.get(this.props.name);
|
|
85
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
86
|
+
if(modalResult) {
|
|
87
|
+
if(!prevProps.modalResult || (prevProps.modalResult.visible !== modalResult.visible)) {
|
|
88
|
+
if(modalResult.visible) {
|
|
89
|
+
this.eventListener.init();
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.eventListener.exit();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
willUnmount() {
|
|
99
|
+
this.eventListener.exit();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
hide() {
|
|
103
|
+
this.updateState({
|
|
104
|
+
fileName: {$set: ''},
|
|
105
|
+
fileType: {$set: ''},
|
|
106
|
+
template: {$set: null},
|
|
107
|
+
dynamicTemplateName: {$set: ''},
|
|
108
|
+
dynamicTemplateNames: {$set: []},
|
|
109
|
+
dynamicTemplateHeading: {$set: ''},
|
|
110
|
+
dynamicTemplate2Index: {$set: -1},
|
|
111
|
+
dynamicTemplate2Names: {$set: []},
|
|
112
|
+
dynamicTemplate2MarkupNodes: {$set: []},
|
|
113
|
+
dynamicTemplate2MarkupStyles: {$set: []},
|
|
114
|
+
dynamicTemplate2Markups: {$set: []},
|
|
115
|
+
dynamicTemplate2Heading: {$set: ''},
|
|
116
|
+
valid: {$set: false},
|
|
117
|
+
error: {$set: false},
|
|
118
|
+
errorText: {$set: ''}
|
|
119
|
+
});
|
|
120
|
+
this.props.onHide();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
new() {
|
|
124
|
+
this.props.onFileNew(this.props.folder.projectId, `${this.props.folder.data.path}/${this.props.folder.title}`, this.state.fileName, this.state.template.type, this.state.template.name, this.state.dynamicTemplateName, -1 !== this.state.dynamicTemplate2Index ? this.state.dynamicTemplate2Names[this.state.dynamicTemplate2Index] : null);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
_keyDown(e) {
|
|
128
|
+
if(!e.ctrlKey && !e.shiftKey && 'Enter' === e.key) {
|
|
129
|
+
if(!this.state.error) {
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
this.new();
|
|
132
|
+
this.hide();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else if(e.ctrlKey && e.shiftKey && 'C' === e.key) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
this.hide();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
renderErrorMessage() {
|
|
142
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
143
|
+
if(this.state.error || 'error' === modalResult?.result.code) {
|
|
144
|
+
const msg = this.state.error ? this.state.errorText : modalResult.result.msg;
|
|
145
|
+
const errorDivStyle = {
|
|
146
|
+
float: 'left',
|
|
147
|
+
textAlign: 'left',
|
|
148
|
+
width: 420
|
|
149
|
+
};
|
|
150
|
+
const labelStyle = {
|
|
151
|
+
top: '2px',
|
|
152
|
+
position: 'relative'
|
|
153
|
+
};
|
|
154
|
+
return (
|
|
155
|
+
<div style={errorDivStyle}>
|
|
156
|
+
<p id="file_new_modal_error_label" className="text-danger control-label modal_body_p_as_label" style={labelStyle}>{msg}</p>
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
rendertemplateNameOptions() {
|
|
166
|
+
if(this.props.templateNames) {
|
|
167
|
+
return this.props.templateNames.map((template, index) => {
|
|
168
|
+
return (
|
|
169
|
+
<option key={index} value={template.name}>
|
|
170
|
+
{template.name}
|
|
171
|
+
</option>
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
renderIcon() {
|
|
178
|
+
if(this.props.onRenderIcon) {
|
|
179
|
+
return (
|
|
180
|
+
<>
|
|
181
|
+
{this.props.onRenderIcon(this.state.template, this.state.dynamicTemplateName)}
|
|
182
|
+
</>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
renderTemplates() {
|
|
188
|
+
return (
|
|
189
|
+
<>
|
|
190
|
+
<br />
|
|
191
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
192
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_START}>
|
|
193
|
+
<label htmlFor="modal_dialog_file_new_template_name" className="control-label">Type</label>
|
|
194
|
+
</div>
|
|
195
|
+
<div className={this.state.template.icon ? ModalDialogFileNew.COLUMN_LIST_WITH_ICON : ModalDialogFileNew.COLUMN_LIST_END}>
|
|
196
|
+
<select id="modal_dialog_file_new_template_name" className="form-control input-sm" value={this.state.template.name}
|
|
197
|
+
onChange={(e) => {
|
|
198
|
+
const template = this._getTemplate(e.target.value);
|
|
199
|
+
if(this.props.onTemplate) {
|
|
200
|
+
const dynamicTemplate = this.props.onTemplate(template.name);
|
|
201
|
+
if(dynamicTemplate) {
|
|
202
|
+
this.updateState({dynamicTemplateNames: {$set: dynamicTemplate.names}, dynamicTemplateHeading: {$set: dynamicTemplate.heading}});
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
this.updateState({dynamicTemplateNames: {$set: []}, dynamicTemplateHeading: {$set: ''}});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
this.updateState({template: {$set: template}});
|
|
209
|
+
this.updateState({dynamicTemplateName: {$set: ''}});
|
|
210
|
+
this.updateState({dynamicTemplate2Index: {$set: -1}});
|
|
211
|
+
this.updateState({dynamicTemplate2Names: {$set: []}});
|
|
212
|
+
this.updateState({dynamicTemplate2MarkupNodes: {$set: []}});
|
|
213
|
+
this.updateState({dynamicTemplate2MarkupStyles: {$set: []}});
|
|
214
|
+
this.updateState({dynamicTemplate2Markups: {$set: []}});
|
|
215
|
+
this.updateState({dynamicTemplate2Heading: {$set: ''}});
|
|
216
|
+
}}
|
|
217
|
+
>
|
|
218
|
+
{this.rendertemplateNameOptions()}
|
|
219
|
+
</select>
|
|
220
|
+
</div>
|
|
221
|
+
{this.renderIcon()}
|
|
222
|
+
</div>
|
|
223
|
+
</>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
renderdynamicTemplateNameOptions() {
|
|
228
|
+
return this.state.dynamicTemplateNames.map((dynamicTemplateName, index) => {
|
|
229
|
+
return (
|
|
230
|
+
<option key={index} value={dynamicTemplateName}>{dynamicTemplateName}</option>
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
renderDynamicTemplates() {
|
|
236
|
+
if(0 !== this.state.dynamicTemplateNames.length) {
|
|
237
|
+
return (
|
|
238
|
+
<>
|
|
239
|
+
<br />
|
|
240
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
241
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_START}>
|
|
242
|
+
<label htmlFor="modal_dialog_file_new_stack_template_name" className="control-label">{this.state.dynamicTemplateHeading}</label>
|
|
243
|
+
</div>
|
|
244
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_END}>
|
|
245
|
+
<select id="modal_dialog_file_new_stack_template_name" className="form-control input-sm" value={this.state.dynamicTemplateName}
|
|
246
|
+
onChange={(e) => {
|
|
247
|
+
const dynamicTemplateName = e.target.value;
|
|
248
|
+
if(this.props.onDynamicTemplate) {
|
|
249
|
+
const dynamicTemplate2 = this.props.onDynamicTemplate(this.state.template.name, dynamicTemplateName);
|
|
250
|
+
if(dynamicTemplate2) {
|
|
251
|
+
this.updateState({
|
|
252
|
+
dynamicTemplate2Names: {$set: dynamicTemplate2.names},
|
|
253
|
+
dynamicTemplate2Index: {$set: 0},
|
|
254
|
+
dynamicTemplate2MarkupNodes: {$set: dynamicTemplate2.markupNodes},
|
|
255
|
+
dynamicTemplate2MarkupStyles: {$set: dynamicTemplate2.markupStyles},
|
|
256
|
+
dynamicTemplate2Markups: {$set: dynamicTemplate2.markups},
|
|
257
|
+
dynamicTemplate2Heading: {$set: dynamicTemplate2.heading}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
this.updateState({
|
|
262
|
+
dynamicTemplate2Names: {$set: []},
|
|
263
|
+
dynamicTemplate2Index: {$set: -1},
|
|
264
|
+
dynamicTemplate2MarkupNodes: {$set: []},
|
|
265
|
+
dynamicTemplate2MarkupStyles: {$set: []},
|
|
266
|
+
dynamicTemplate2Markups: {$set: []},
|
|
267
|
+
dynamicTemplate2Heading: {$set: ''}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
this.updateState({dynamicTemplateName: {$set: e.target.value}});
|
|
272
|
+
}}
|
|
273
|
+
>
|
|
274
|
+
{this.renderdynamicTemplateNameOptions()}
|
|
275
|
+
</select>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</>
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
renderdynamicTemplateNameOptions2() {
|
|
284
|
+
return this.state.dynamicTemplate2Names.map((dynamicTemplateName2, index) => {
|
|
285
|
+
return (
|
|
286
|
+
<option key={index} value={dynamicTemplateName2}>{dynamicTemplateName2}</option>
|
|
287
|
+
);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
renderDynamicTemplates2() {
|
|
292
|
+
if(0 !== this.state.dynamicTemplate2Names.length) {
|
|
293
|
+
return (
|
|
294
|
+
<>
|
|
295
|
+
<br />
|
|
296
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
297
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_START}>
|
|
298
|
+
<label htmlFor="modal_dialog_file_new_stack_template_name" className="control-label">{this.state.dynamicTemplate2Heading}</label>
|
|
299
|
+
</div>
|
|
300
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_END}>
|
|
301
|
+
<select id="modal_dialog_file_new_stack_template_name" className="form-control input-sm" value={this.state.dynamicTemplate2Names[this.state.dynamicTemplate2Index]}
|
|
302
|
+
onChange={(e) => {
|
|
303
|
+
const index = this.state.dynamicTemplate2Names.indexOf(e.target.value);
|
|
304
|
+
this.updateState({dynamicTemplate2Index: {$set: index}});
|
|
305
|
+
}}
|
|
306
|
+
>
|
|
307
|
+
{this.renderdynamicTemplateNameOptions2()}
|
|
308
|
+
</select>
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
renderMarkup() {
|
|
317
|
+
if(0 !== this.state.dynamicTemplate2Names.length) {
|
|
318
|
+
if(-1 !== this.state.dynamicTemplate2Index) {
|
|
319
|
+
const document = MarkupDocumentationPage.parse(this.state.dynamicTemplate2Markups[this.state.dynamicTemplate2Index]);
|
|
320
|
+
const style = {marginTop:'-16px'};
|
|
321
|
+
const dynamicStyle = this.state.dynamicTemplate2MarkupStyles[this.state.dynamicTemplate2Index];
|
|
322
|
+
if(dynamicStyle) {
|
|
323
|
+
Object.assign(style, dynamicStyle);
|
|
324
|
+
}
|
|
325
|
+
return (
|
|
326
|
+
<div style={style}>
|
|
327
|
+
<ComponentDocument document={document} waitMount></ComponentDocument>
|
|
328
|
+
</div>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
const document = MarkupDocumentationPage.parse(this.state.template.markup);
|
|
334
|
+
const style = {marginTop:'-16px'};
|
|
335
|
+
Object.assign(style, this.state.template.markupStyle);
|
|
336
|
+
return (
|
|
337
|
+
<div style={style}>
|
|
338
|
+
<ComponentDocument document={document}></ComponentDocument>
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
renderFileTypeOptions() {
|
|
345
|
+
if(null !== this.props.folder) {
|
|
346
|
+
return this.props.folder.data.types.map((type, index) => {
|
|
347
|
+
return (
|
|
348
|
+
<option key={index} value={type}>{type}</option>
|
|
349
|
+
);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
renderFileType() {
|
|
355
|
+
if(this.props.fileType) {
|
|
356
|
+
return (
|
|
357
|
+
<>
|
|
358
|
+
<br />
|
|
359
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
360
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_START}>
|
|
361
|
+
<label htmlFor="modal_dialog_file_new_file_type" className="control-label">File Type</label>
|
|
362
|
+
</div>
|
|
363
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_END}>
|
|
364
|
+
<select id="modal_dialog_file_new_file_type" className="form-control input-sm" value={this.state.fileType}
|
|
365
|
+
onChange={(e) => {
|
|
366
|
+
this.updateState({fileType: {$set: e.target.value}});
|
|
367
|
+
}}
|
|
368
|
+
>
|
|
369
|
+
{this.renderFileTypeOptions()}
|
|
370
|
+
</select>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
</>
|
|
374
|
+
)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
renderInner(show) {
|
|
379
|
+
if(show) {
|
|
380
|
+
return (
|
|
381
|
+
<>
|
|
382
|
+
{this.renderTemplates()}
|
|
383
|
+
{this.renderDynamicTemplates()}
|
|
384
|
+
{this.renderDynamicTemplates2()}
|
|
385
|
+
{this.renderFileType()}
|
|
386
|
+
</>
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
return null;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
render() {
|
|
395
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
396
|
+
const markupNodes = 0 === this.state.dynamicTemplate2Names.length ? 2 : this.state.dynamicTemplate2MarkupNodes[this.state.dynamicTemplate2Index];
|
|
397
|
+
const infoStyle = {
|
|
398
|
+
width: 3 === markupNodes ? '308px' : '178px',
|
|
399
|
+
height: 0 === this.state.dynamicTemplateNames.length ? (this.props.fileType ? '130px' : '80px') : (0 === this.state.dynamicTemplate2Names.length ? (this.props.fileType ? '180px' : '130px') : (this.props.fileType ? '230px': '180px')),
|
|
400
|
+
position: 'absolute',
|
|
401
|
+
right: '16px',
|
|
402
|
+
borderRadius: '3px',
|
|
403
|
+
border: 'solid 1.5px lightgray',
|
|
404
|
+
overflow: 'hidden',
|
|
405
|
+
backgroundColor: 'AliceBlue'
|
|
406
|
+
};
|
|
407
|
+
const width = 3 === markupNodes ? '730px' : undefined;
|
|
408
|
+
const show = !!modalResult?.visible;
|
|
409
|
+
this.helperModalPopover.onRender();
|
|
410
|
+
return (
|
|
411
|
+
<Modal ref={this.helperModalPopover.modalRef} id="modal_file_new" aria-labelledby="contained-modal-title-sm" show={show}
|
|
412
|
+
onShown={(e) => {
|
|
413
|
+
this.inputRef.current.focus();
|
|
414
|
+
}}
|
|
415
|
+
onHide={(e) => {
|
|
416
|
+
this.hide();
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
<ModalHeader closeButton>
|
|
420
|
+
<img className="modal_header_icon pull-left" src="/abs-images/svg/ActorJsA.svg" alt="ActorJs Icon"></img>
|
|
421
|
+
<h4 className="modal_header_heading modal-sm">{this.props.heading}</h4>
|
|
422
|
+
</ModalHeader>
|
|
423
|
+
<ModalBody>
|
|
424
|
+
<div style={infoStyle}>
|
|
425
|
+
{this.renderMarkup()}
|
|
426
|
+
</div>
|
|
427
|
+
<div className="form-group">
|
|
428
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
429
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_START}>
|
|
430
|
+
<label htmlFor="modal_dialog_file_new_name" className="control-label">Name</label>
|
|
431
|
+
</div>
|
|
432
|
+
<div className={ModalDialogFileNew.COLUMN_LIST_END}>
|
|
433
|
+
<input ref={this.inputRef} id="modal_dialog_file_new_name" type="text" className="form-control input-sm" placeholder="file name" value={this.state.fileName}
|
|
434
|
+
onChange={(e) => {
|
|
435
|
+
const result = this.inputAnalyzer.analyze(e.target.value);
|
|
436
|
+
if(result.success) {
|
|
437
|
+
this.updateState({valid: {$set: true}});
|
|
438
|
+
this.updateState({error: {$set: false}});
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
this.updateState({valid: {$set: false}});
|
|
442
|
+
this.updateState({error: {$set: true}});
|
|
443
|
+
if(!result.regexpValidation) {
|
|
444
|
+
this.updateState({errorText: {$set: `The name contains not allowed characters: '${result.noneValidCharacters}'`}});
|
|
445
|
+
}
|
|
446
|
+
else if(!result.filenameValidation) {
|
|
447
|
+
this.updateState({errorText: {$set: `The filename is not allowed: '${result.noneValidFilename}'`}});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
this.updateState({fileName: {$set: e.target.value}});
|
|
451
|
+
}}
|
|
452
|
+
/>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
{this.renderInner(show)}
|
|
456
|
+
</div>
|
|
457
|
+
</ModalBody>
|
|
458
|
+
<ModalFooter>
|
|
459
|
+
{this.renderErrorMessage()}
|
|
460
|
+
<Popover ref={this.helperModalPopover.getPopoverRef()} placement="bottom" heading="" content="" shortcut="Enter" style={{display:'inline-block'}} disabled={!show}>
|
|
461
|
+
<button id="file_new_new_button" type="button" className="btn btn-primary" disabled={0 === this.state.fileName.length || !this.state.valid}
|
|
462
|
+
onClick={(e) => {
|
|
463
|
+
this.new();
|
|
464
|
+
}}
|
|
465
|
+
>New</button>
|
|
466
|
+
</Popover>
|
|
467
|
+
<Popover ref={this.helperModalPopover.getPopoverRef()} placement="bottom" heading="" content="" shortcut="Ctrl+Shift+C" style={{display:'inline-block',marginLeft:'5px'}} disabled={!show}>
|
|
468
|
+
<button id="file_new_close_button" type="button" className="btn btn-default" disabled={!show}
|
|
469
|
+
onClick={(e) => {
|
|
470
|
+
this.hide();
|
|
471
|
+
}}
|
|
472
|
+
>Close</button>
|
|
473
|
+
</Popover>
|
|
474
|
+
</ModalFooter>
|
|
475
|
+
</Modal>
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
_getTemplate(name) {
|
|
480
|
+
return this.props.templateNames.find((template) => {
|
|
481
|
+
return template.name === name;
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
ModalDialogFileNew.COLUMN_LIST_START = 'col_sm_2';
|
|
488
|
+
ModalDialogFileNew.COLUMN_LIST_WITH_ICON = 'col_sm_5_5';
|
|
489
|
+
ModalDialogFileNew.COLUMN_LIST_END = 'col_sm_6';
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import HelperEventListener from './helper/helper-event-listener';
|
|
5
|
+
import HelperModalPopover from './helper/helper-modal-popover';
|
|
6
|
+
import InputAnalyzer from './helper/input-analyzer';
|
|
7
|
+
import Modal from 'z-abs-complayer-bootstrap-client/client/modal';
|
|
8
|
+
import ModalHeader from 'z-abs-complayer-bootstrap-client/client/modal-header';
|
|
9
|
+
import ModalBody from 'z-abs-complayer-bootstrap-client/client/modal-body';
|
|
10
|
+
import ModalFooter from 'z-abs-complayer-bootstrap-client/client/modal-footer';
|
|
11
|
+
import Popover from 'z-abs-complayer-bootstrap-client/client/popover';
|
|
12
|
+
import ReactComponentBase from 'z-abs-corelayer-client/client/react-component/react-component-base';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export default class ModalDialogFileProperties extends ReactComponentBase {
|
|
17
|
+
constructor(props) {
|
|
18
|
+
super(props, {
|
|
19
|
+
fileName: '',
|
|
20
|
+
valid: false,
|
|
21
|
+
error: false,
|
|
22
|
+
errorText: ''
|
|
23
|
+
});
|
|
24
|
+
this.helperModalPopover = new HelperModalPopover();
|
|
25
|
+
this.inputRef = React.createRef();
|
|
26
|
+
this.inputAnalyzer = new InputAnalyzer(this.props.capitalFirst ? true : false);
|
|
27
|
+
this.eventListener = new HelperEventListener('keydown', this._keyDown.bind(this), true);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
didMount() {
|
|
31
|
+
this.helperModalPopover.didMount();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
shouldUpdate(nextProps, nextState) {
|
|
35
|
+
return !this.shallowCompare(this.props, nextProps)
|
|
36
|
+
|| !this.shallowCompare(this.props.modalResults, nextProps.modalResults)
|
|
37
|
+
|| !this.shallowCompare(this.state, nextState);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
didUpdate(prevProps, prevState) {
|
|
41
|
+
const previousModalResult = prevProps.modalResults.get(this.props.name);
|
|
42
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
43
|
+
if(modalResult) {
|
|
44
|
+
if(!prevProps.modalResult || (prevProps.modalResult.visible !== modalResult.visible)) {
|
|
45
|
+
if(modalResult.visible) {
|
|
46
|
+
this.eventListener.init();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.eventListener.exit();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
willUnmount() {
|
|
56
|
+
this.eventListener.exit();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
update() {
|
|
60
|
+
this.props.onFileProperties(this.props.file.projectId, this.props.file.path, this.props.file.title, `${this.state.fileName}.${this._getFileExtension(this.props.file)}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
hide() {
|
|
64
|
+
this.updateState({
|
|
65
|
+
fileName: {$set: ''},
|
|
66
|
+
valid: {$set: false},
|
|
67
|
+
error: {$set: false},
|
|
68
|
+
errorText: {$set: ''}
|
|
69
|
+
});
|
|
70
|
+
this.props.onHide();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
_keyDown(e) {
|
|
74
|
+
if(!e.ctrlKey && !e.shiftKey && 'Enter' === e.key) {
|
|
75
|
+
if(!this.state.error) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
this.update();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if(e.ctrlKey && e.shiftKey && 'C' === e.key) {
|
|
81
|
+
e.preventDefault();
|
|
82
|
+
this.hide();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
renderErrorMessage() {
|
|
87
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
88
|
+
if(this.state.error || 'error' === modalResult?.result.code) {
|
|
89
|
+
const msg = this.state.error ? this.state.errorText : modalResult.result.msg;
|
|
90
|
+
const errorDivStyle = {
|
|
91
|
+
float: 'left',
|
|
92
|
+
textAlign: 'left',
|
|
93
|
+
width: 420
|
|
94
|
+
};
|
|
95
|
+
const labelStyle = {
|
|
96
|
+
top: '2px',
|
|
97
|
+
position: 'relative'
|
|
98
|
+
};
|
|
99
|
+
return (
|
|
100
|
+
<div style={errorDivStyle}>
|
|
101
|
+
<p id="file_properties_modal_error_label" className="text-danger control-label modal_body_p_as_label" style={labelStyle}>{msg}</p>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
const modalResult = this.props.modalResults.get(this.props.name);
|
|
112
|
+
const show = !!modalResult?.visible;
|
|
113
|
+
this.helperModalPopover.onRender();
|
|
114
|
+
return (
|
|
115
|
+
<Modal ref={this.helperModalPopover.modalRef} id="modal_file_properties" aria-labelledby="contained-modal-title-sm" show={show}
|
|
116
|
+
onShown={(e) => {
|
|
117
|
+
this.inputRef.current.select();
|
|
118
|
+
}}
|
|
119
|
+
onHide={(e) => {
|
|
120
|
+
this.hide();
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<ModalHeader closeButton>
|
|
124
|
+
<img className="modal_header_icon pull-left" src="/abs-images/svg/ActorJsA.svg" alt="ActorJs Icon"></img>
|
|
125
|
+
<h4 className="modal_header_heading modal-sm">{this.props.heading}</h4>
|
|
126
|
+
</ModalHeader>
|
|
127
|
+
<ModalBody>
|
|
128
|
+
<div className="form-group">
|
|
129
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
130
|
+
<div className="col-sm-2">
|
|
131
|
+
<label htmlFor="modal_dialog_file_properties_name_input" className="control-label">Name</label>
|
|
132
|
+
</div>
|
|
133
|
+
<div className="col-sm-9">
|
|
134
|
+
<input ref={this.inputRef} id="modal_dialog_file_properties_name_input" type="text" className="form-control input-sm" placeholder="file name" value={this.state.fileName ? this.state.fileName : this._getFileName(this.props.file)}
|
|
135
|
+
onChange={(e) => {
|
|
136
|
+
const result = this.inputAnalyzer.analyze(e.target.value);
|
|
137
|
+
if(result.success) {
|
|
138
|
+
this.updateState({valid: {$set: true}});
|
|
139
|
+
this.updateState({error: {$set: false}});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.updateState({valid: {$set: false}});
|
|
143
|
+
this.updateState({error: {$set: true}});
|
|
144
|
+
if(!result.regexpValidation) {
|
|
145
|
+
this.updateState({errorText: {$set: `The name contains not allowed characters: '${result.noneValidCharacters}'`}});
|
|
146
|
+
}
|
|
147
|
+
else if(!result.filenameValidation) {
|
|
148
|
+
this.updateState({errorText: {$set: `The filename is not allowed: '${result.noneValidFilename}'`}});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
this.updateState({fileName: {$set: e.target.value}});
|
|
152
|
+
}}
|
|
153
|
+
/>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
<div className="row" style={{textAlign: 'right'}}>
|
|
157
|
+
<div className="col-sm-2">
|
|
158
|
+
<p className="control-label modal_body_p_as_label">File name</p>
|
|
159
|
+
</div>
|
|
160
|
+
<div className="col-sm-9" style={{textAlign: 'left'}}>
|
|
161
|
+
<p className="control-label modal_body_p_as_label">{`${this.state.fileName ? this.state.fileName : this._getFileName(this.props.file)}.${this._getFileExtension(this.props.file)}`}</p>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</ModalBody>
|
|
166
|
+
<ModalFooter>
|
|
167
|
+
{this.renderErrorMessage()}
|
|
168
|
+
<Popover ref={this.helperModalPopover.getPopoverRef()} placement="bottom" heading="" content="" shortcut="Enter" style={{display:'inline-block'}} disabled={!show}>
|
|
169
|
+
<button id="file_properties_change_button" type="button" className="btn btn-primary" disabled={(0 === this.state.fileName.length || this._getFileName(this.props.file) === this.state.fileName || !this.state.valid)}
|
|
170
|
+
onClick={(e) => {
|
|
171
|
+
this.update();
|
|
172
|
+
}}
|
|
173
|
+
>Change</button>
|
|
174
|
+
</Popover>
|
|
175
|
+
<Popover ref={this.helperModalPopover.getPopoverRef()} placement="bottom" heading="" content="" shortcut="Ctrl+Shift+C" style={{display:'inline-block',marginLeft:'5px'}} disabled={!show}>
|
|
176
|
+
<button id="file_properties_close_button" type="button" className="btn btn-default" disabled={!show}
|
|
177
|
+
onClick={(e) => {
|
|
178
|
+
this.hide();
|
|
179
|
+
}}
|
|
180
|
+
>Close</button>
|
|
181
|
+
</Popover>
|
|
182
|
+
</ModalFooter>
|
|
183
|
+
</Modal>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
_getFileName(file) {
|
|
188
|
+
if(file) {
|
|
189
|
+
const index = file.title.indexOf('.');
|
|
190
|
+
return file.title.substring(0, index);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
return 'NONE';
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
_getFileExtension(file) {
|
|
198
|
+
if(file) {
|
|
199
|
+
const index = file.title.indexOf('.');
|
|
200
|
+
return file.title.substring(index + 1);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return 'NONE';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|