Skip to content

Commit 804a0d6

Browse files
author
Ben Helleman
committed
change the order of the fields and provide help text
1 parent 6131f91 commit 804a0d6

File tree

4 files changed

+63
-29
lines changed

4 files changed

+63
-29
lines changed

css/import/import.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,25 @@
213213
display: flex;
214214
}
215215

216+
.import .docx-or-jcr {
217+
display: flex;
218+
}
219+
220+
.import .docx-or-jcr-selection {
221+
display: flex;
222+
}
223+
216224
/* if the open class is missing then hide the fields */
217225
.import #jcr-package-fields {
218226
display: none;
219227
}
228+
229+
.import .local-save {
230+
padding-top: 10px;
231+
}
232+
233+
.import .docx-or-jcr-selection sp-contextual-help > * {
234+
width: 268px;
235+
max-width: 268px;
236+
}
237+

css/styles.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ section .page-preview iframe {
370370
}
371371

372372
/* Contextual Help */
373-
sp-contextual-help > * {
374-
width: 268px;
375-
max-width: 268px;
376-
}
373+
sp-contextual-help > * {
374+
width: 268px;
375+
max-width: 268px;
376+
}

import.html

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,26 @@ <h3>Workbench</h3>
7272
format-options='{ "style": "unit", "unit": "millisecond", "unitDisplay": "short" }'></sp-number-field>
7373

7474
<div class="local-save">
75-
<sp-checkbox class="option-field" id="import-local-docx" checked>
76-
Save as docx
77-
</sp-checkbox>
78-
<sp-checkbox class="option-field" id="import-local-html">
79-
Save as HTML
80-
</sp-checkbox>
81-
<sp-checkbox class="option-field" id="import-local-md">
82-
Save as Markdown
83-
</sp-checkbox>
84-
<sp-checkbox class="option-field" id="import-jcr-package">
85-
Save as JCR Package
86-
</sp-checkbox>
87-
<!-- Fields to be dynamically displayed -->
75+
<div class="docx-or-jcr-selection">
76+
<sp-help-text size="m" slot="help-text">
77+
Select either doc based or crosswalk.
78+
</sp-help-text>
79+
<sp-contextual-help placement="top-start">
80+
<h3 slot="heading">Document or Crosswalk Project?</h3>
81+
<p>Select the target output format before importing the content.
82+
Selecting Save as docx, will save the content as a docx file.
83+
Selecting Save as JCR Package, will save the content as a JCR package.</p>
84+
</sp-contextual-help>
85+
</div>
86+
<div class="docx-or-jcr">
87+
<sp-checkbox class="option-field" id="import-local-docx" checked>
88+
Save as docx
89+
</sp-checkbox>
90+
<sp-checkbox class="option-field" id="import-jcr-package">
91+
Save as JCR Package
92+
</sp-checkbox>
93+
<!-- Fields to be dynamically displayed -->
94+
</div>
8895
<div id="jcr-package-fields">
8996
<div>
9097
<sp-field-label for="jcr-site-folder" required>AEM Site's folder name</sp-field-label>
@@ -95,6 +102,12 @@ <h3>Workbench</h3>
95102
<sp-textfield id="jcr-asset-folder" type="text" class="textfield"></sp-textfield>
96103
</div>
97104
</div>
105+
<sp-checkbox class="option-field" id="import-local-html">
106+
Save as HTML
107+
</sp-checkbox>
108+
<sp-checkbox class="option-field" id="import-local-md">
109+
Save as Markdown
110+
</sp-checkbox>
98111
</div>
99112

100113
<sp-checkbox class="option-field" id="import-enable-js">

js/import/import.ui.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,30 @@ const enableProcessButtons = () => {
8585
};
8686

8787
const toggleJcrFields = () => {
88-
if (SAVE_AS_JCR_PACKAGE.checked) {
89-
JCR_PACKAGE_FIELDS.classList.add('open');
90-
} else {
91-
JCR_PACKAGE_FIELDS.classList.remove('open');
92-
}
88+
JCR_PACKAGE_FIELDS.classList.toggle('open', SAVE_AS_JCR_PACKAGE.checked);
9389

9490
// if SAVE_AS_DOCX is checked, uncheck it as only JCR or DOC can be selected
95-
if (SAVE_AS_JCR_PACKAGE.checked) {
96-
SAVE_AS_DOCX.checked = false;
97-
}
91+
92+
// update our fields
93+
config.fields['import-jcr-package'] = SAVE_AS_JCR_PACKAGE.checked;
94+
config.fields['import-local-docx'] = !SAVE_AS_JCR_PACKAGE.checked;;
95+
96+
SAVE_AS_DOCX.checked = !SAVE_AS_JCR_PACKAGE.checked;
9897

9998
// initial state setup, if the fields are empty, mark them as invalid
10099
JCR_SITE_FOLDER.invalid = localStorage.getItem(`textfield-${JCR_SITE_FOLDER.id}`) === '';
101100
JCR_ASSET_FOLDER.invalid = localStorage.getItem(`textfield-${JCR_ASSET_FOLDER.id}`) === '';
102101
};
103102

104103
const saveAsDocListener = () => {
105-
// when the SAVE_AS_DOCX checkbox is checked, the JCR_PACKAGE_FIELDS should deselected
104+
// update our fields
105+
config.fields['import-local-docx'] = SAVE_AS_DOCX.checked;
106+
config.fields['import-jcr-package'] = !SAVE_AS_DOCX.checked;
107+
108+
SAVE_AS_JCR_PACKAGE.checked = !SAVE_AS_DOCX.checked;
109+
106110
if (SAVE_AS_DOCX.checked) {
107-
SAVE_AS_JCR_PACKAGE.checked = false;
108-
JCR_PACKAGE_FIELDS.classList.remove('open');
111+
JCR_PACKAGE_FIELDS.classList.toggle('open', !SAVE_AS_DOCX.checked);
109112
}
110113
};
111114

@@ -166,7 +169,7 @@ const postSuccessfulStep = async (results, originalURL) => {
166169
// save all other files (doc, html, md)
167170
files.forEach((file) => {
168171
try {
169-
const filePath = files.length > 1 ? `/${file.type}${file.filename}` : file.filename;
172+
const filePath = `/${file.type}${file.filename}`;
170173
saveFile(dirHandle, filePath, file.data);
171174
data.file = filePath;
172175
data.status = 'Success';

0 commit comments

Comments
 (0)