@plusscommunities/pluss-feature-builder-web-b 1.0.2-beta.7 → 1.0.4-beta.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/dist/index.cjs.js +123 -96
- package/package.json +11 -11
- package/src/actions/formActions.js +148 -148
- package/src/actions/wizardActions.js +166 -166
- package/src/components/BaseFieldConfig.jsx +3 -3
- package/src/components/ListingEditor.jsx +2 -2
- package/src/components/SidebarLayout.jsx +4 -4
- package/src/components/listing/ListingFileInput.jsx +98 -80
- package/src/components/listing/ListingFileInput.module.css +1 -4
- package/src/components/listing/ListingGalleryInput.module.css +2 -1
- package/src/images/full.png +0 -0
- package/src/images/fullNoTitle.png +0 -0
- package/src/images/previewWidget.png +0 -0
- package/src/images/widget.png +0 -0
- package/src/reducers/featureBuilderReducer.js +12 -6
- package/src/screens/FormLayoutStep.jsx +421 -420
- package/src/screens/FormOverviewStep.jsx +349 -349
- package/src/selectors/featureBuilderSelectors.js +1 -6
- package/src/values.config.default.js +49 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
selectFormTitle,
|
|
3
|
+
selectFormIcon,
|
|
4
|
+
selectFormDisplayName,
|
|
5
|
+
selectFormLayout,
|
|
6
|
+
selectFormFields,
|
|
7
7
|
} from "../selectors/featureBuilderSelectors";
|
|
8
8
|
|
|
9
|
-
import { clearFormSubmissionState } from "./formActions"
|
|
9
|
+
import { clearFormSubmissionState } from "./formActions";
|
|
10
10
|
|
|
11
11
|
import { values } from "../values.config";
|
|
12
12
|
|
|
@@ -21,208 +21,208 @@ export const VALIDATE_AND_UPDATE_STEP = `${REDUCER_PREFIX}_VALIDATE_AND_UPDATE_S
|
|
|
21
21
|
|
|
22
22
|
// Mode setters
|
|
23
23
|
export const setWizardMode = (mode) => ({
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
type: SET_WIZARD_MODE,
|
|
25
|
+
payload: mode,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// Navigation actions
|
|
29
29
|
export const setNavigationState = (navigationState) => ({
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
type: SET_NAVIGATION_STATE,
|
|
31
|
+
payload: navigationState,
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
export const setCurrentStep = (step, previousStep = null) => ({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
type: SET_NAVIGATION_STATE,
|
|
36
|
+
payload: {
|
|
37
|
+
currentStep: step,
|
|
38
|
+
previousStep,
|
|
39
|
+
canGoBack: step !== "welcome",
|
|
40
|
+
canGoForward: true,
|
|
41
|
+
},
|
|
42
42
|
});
|
|
43
43
|
|
|
44
44
|
export const goToStep = (step) => (dispatch, getState) => {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const state = getState()[values.reducerKey];
|
|
46
|
+
const currentStep = state?.wizard?.navigation?.currentStep;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// Clear form submission state when changing steps
|
|
49
|
+
dispatch(clearFormSubmissionState());
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
dispatch(setCurrentStep(step, currentStep));
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
export const updateStepValidation = (step, isValid, errors = {}) => ({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
type: UPDATE_STEP_VALIDATION,
|
|
56
|
+
payload: {
|
|
57
|
+
step,
|
|
58
|
+
isValid,
|
|
59
|
+
errors,
|
|
60
|
+
},
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
export const validateAndUpdateStep = (step) => (dispatch, getState) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
// Use existing selectors to get form data
|
|
65
|
+
const state = getState();
|
|
66
|
+
const title = selectFormTitle(state);
|
|
67
|
+
const icon = selectFormIcon(state);
|
|
68
|
+
const displayName = selectFormDisplayName(state);
|
|
69
|
+
const layout = selectFormLayout(state);
|
|
70
|
+
const fields = selectFormFields(state);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
const form = { title, icon, displayName, layout, fields };
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
const { isValid, errors } = getFormValidation(form, step);
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
// If valid, mark as complete
|
|
79
|
+
if (isValid) {
|
|
80
|
+
dispatch({
|
|
81
|
+
type: MARK_STEP_COMPLETE,
|
|
82
|
+
payload: step,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
return { isValid, errors };
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
// Step completion
|
|
90
90
|
export const markStepComplete = (step) => ({
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
type: MARK_STEP_COMPLETE,
|
|
92
|
+
payload: step,
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
// Reset wizard state
|
|
96
96
|
export const resetWizardState = () => ({
|
|
97
|
-
|
|
97
|
+
type: RESET_WIZARD_STATE,
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
const getFormValidation = (form, step) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
101
|
+
// Return validation results for undefined form (prevent crashes)
|
|
102
|
+
if (!form) {
|
|
103
|
+
switch (step) {
|
|
104
|
+
case "overview":
|
|
105
|
+
return {
|
|
106
|
+
isValid: false,
|
|
107
|
+
errors: {
|
|
108
|
+
title: "Title is required",
|
|
109
|
+
displayName: "Display name is required",
|
|
110
|
+
icon: "Icon is required",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
case "fields":
|
|
114
|
+
return {
|
|
115
|
+
isValid: false,
|
|
116
|
+
errors: {
|
|
117
|
+
missingTitle: "Title field is required",
|
|
118
|
+
missingImage: "Feature image field is required",
|
|
119
|
+
fieldLabels: "Some fields are missing labels",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
case "layout":
|
|
123
|
+
return {
|
|
124
|
+
isValid: false,
|
|
125
|
+
errors: {
|
|
126
|
+
layoutType: "Layout type is required",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
default:
|
|
130
|
+
return { isValid: false, errors: {} };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
switch (step) {
|
|
135
|
+
case "overview": {
|
|
136
|
+
const hasTitle = form.title?.trim().length > 0;
|
|
137
|
+
const hasDisplayName = form.displayName?.trim().length > 0;
|
|
138
|
+
const hasIcon = form.icon?.length > 0;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
isValid: hasTitle && hasDisplayName && hasIcon,
|
|
142
|
+
errors: {
|
|
143
|
+
title: !hasTitle ? "Title is required" : null,
|
|
144
|
+
displayName: !hasDisplayName ? "Display name is required" : null,
|
|
145
|
+
icon: !hasIcon ? "Icon is required" : null,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
case "fields": {
|
|
150
|
+
const hasTitleField = form.fields?.some(
|
|
151
|
+
(field) => field.id === "mandatory-title",
|
|
152
|
+
);
|
|
153
|
+
const hasImageField = form.fields?.some(
|
|
154
|
+
(field) => field.id === "mandatory-feature-image",
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// Check each field for missing labels and create field-specific errors
|
|
158
|
+
const fieldErrors = {};
|
|
159
|
+
let allFieldsHaveLabels = true;
|
|
160
|
+
|
|
161
|
+
if (form.fields) {
|
|
162
|
+
form.fields.forEach((field) => {
|
|
163
|
+
if (
|
|
164
|
+
(field.type === "text" ||
|
|
165
|
+
field.type === "description" ||
|
|
166
|
+
field.type === "title" ||
|
|
167
|
+
field.type === "image" ||
|
|
168
|
+
field.type === "gallery" ||
|
|
169
|
+
field.type === "feature-image" ||
|
|
170
|
+
field.type === "file" ||
|
|
171
|
+
field.type === "cta") &&
|
|
172
|
+
field.values
|
|
173
|
+
) {
|
|
174
|
+
if (!field.values.label || field.values.label.trim().length === 0) {
|
|
175
|
+
fieldErrors[field.id] = "Field label is required";
|
|
176
|
+
allFieldsHaveLabels = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
isValid: hasTitleField && hasImageField && allFieldsHaveLabels,
|
|
184
|
+
errors: {
|
|
185
|
+
missingTitle: !hasTitleField ? "Title field is required" : null,
|
|
186
|
+
missingImage: !hasImageField
|
|
187
|
+
? "Feature image field is required"
|
|
188
|
+
: null,
|
|
189
|
+
...fieldErrors,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "layout": {
|
|
194
|
+
const hasLayoutType = form.layout?.type?.length > 0;
|
|
195
|
+
return {
|
|
196
|
+
isValid: hasLayoutType,
|
|
197
|
+
errors: {
|
|
198
|
+
layoutType: !hasLayoutType ? "Layout type is required" : null,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return { isValid: true, errors: {} };
|
|
204
|
+
}
|
|
205
205
|
};
|
|
206
206
|
|
|
207
207
|
export const setWizardModeAndSave = (mode) => (dispatch) => {
|
|
208
|
-
|
|
208
|
+
dispatch(setWizardMode(mode));
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
export const setCurrentStepAndSave =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
(step, previousStep = null) =>
|
|
213
|
+
(dispatch) => {
|
|
214
|
+
dispatch(setCurrentStep(step, previousStep));
|
|
215
|
+
};
|
|
216
216
|
|
|
217
217
|
export const updateStepValidationAndSave =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
218
|
+
(step, isValid, errors = {}) =>
|
|
219
|
+
(dispatch) => {
|
|
220
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
221
|
+
if (isValid) {
|
|
222
|
+
dispatch(markStepComplete(step));
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
225
|
|
|
226
226
|
export const markStepCompleteAndSave = (step) => (dispatch) => {
|
|
227
|
-
|
|
227
|
+
dispatch(markStepComplete(step));
|
|
228
228
|
};
|
|
@@ -241,10 +241,10 @@ export const BaseFieldConfig = (props) => {
|
|
|
241
241
|
{setMaxImages && (
|
|
242
242
|
<GenericInput
|
|
243
243
|
type="number"
|
|
244
|
-
value={maxImages ||
|
|
245
|
-
placeholder="
|
|
244
|
+
value={maxImages || 16}
|
|
245
|
+
placeholder="16"
|
|
246
246
|
label="Maximum Images"
|
|
247
|
-
onChange={(e) => setMaxImages(parseInt(e.target.value) ||
|
|
247
|
+
onChange={(e) => setMaxImages(parseInt(e.target.value) || 16)}
|
|
248
248
|
className={styles.fieldSpacing}
|
|
249
249
|
alwaysShowLabel
|
|
250
250
|
/>
|
|
@@ -168,8 +168,8 @@ const ListingEditor = ({ mode = "create", listingId, onSuccess, onCancel }) => {
|
|
|
168
168
|
|
|
169
169
|
// formData always has structure { fields: {...} } after our fixes
|
|
170
170
|
const submissionData = isEditMode
|
|
171
|
-
? { id: listingId, fields: formData.fields }
|
|
172
|
-
: { fields: formData.fields };
|
|
171
|
+
? { id: listingId, fields: formData.fields, site: auth.site }
|
|
172
|
+
: { fields: formData.fields, site: auth.site };
|
|
173
173
|
|
|
174
174
|
const actionPromise = dispatch(
|
|
175
175
|
isEditMode ? editListing(submissionData) : createListing(submissionData),
|
|
@@ -84,7 +84,7 @@ const SideBarInner = (props) => {
|
|
|
84
84
|
|
|
85
85
|
// Build sidebar items based on mode
|
|
86
86
|
const buildSidebarItems = () => {
|
|
87
|
-
const isWizardMode = mode === "create"
|
|
87
|
+
const isWizardMode = mode === "create";
|
|
88
88
|
|
|
89
89
|
return steps.map((step, index) => {
|
|
90
90
|
const isCompleted = selectIsStepComplete(step.key);
|
|
@@ -109,8 +109,8 @@ const SideBarInner = (props) => {
|
|
|
109
109
|
isFontAwesome: true,
|
|
110
110
|
// Enhanced completion indicator
|
|
111
111
|
completed: isCompleted,
|
|
112
|
-
// Disable all navigation in
|
|
113
|
-
disabled:
|
|
112
|
+
// Disable all navigation in create mode, otherwise respect accessibility
|
|
113
|
+
disabled: mode === "create" || !isAccessible,
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
return itemProps;
|
|
@@ -137,7 +137,7 @@ const SideBarInner = (props) => {
|
|
|
137
137
|
|
|
138
138
|
// Add effect to manually attach click handlers since HubSidebar might not use onclick properly
|
|
139
139
|
useEffect(() => {
|
|
140
|
-
const isWizardMode = mode === "create"
|
|
140
|
+
const isWizardMode = mode === "create";
|
|
141
141
|
|
|
142
142
|
const attachClickHandlers = () => {
|
|
143
143
|
const stepsWithUrls = [
|