|
Lines 93-100
Link Here
|
| 93 |
!instancedResource.stickyToolbar.includes('Form')) |
93 |
!instancedResource.stickyToolbar.includes('Form')) |
| 94 |
" |
94 |
" |
| 95 |
> |
95 |
> |
| 96 |
<DropdownButtons :dropdownButtons="dropdownButtons" :cssClass="'btn-primary'"> |
96 |
<DropdownButtons |
| 97 |
<ButtonSubmit :title="buttonTextLeader" /> |
97 |
:dropdownButtons="dropdownButtons" |
|
|
98 |
:cssClass="'btn-primary'" |
| 99 |
> |
| 100 |
<ButtonSubmit :title="$__('Save')" /> |
| 98 |
</DropdownButtons> |
101 |
</DropdownButtons> |
| 99 |
<router-link |
102 |
<router-link |
| 100 |
:to="{ name: instancedResource.components.list }" |
103 |
:to="{ name: instancedResource.components.list }" |
|
Lines 114-120
import ButtonSubmit from "./ButtonSubmit.vue";
Link Here
|
| 114 |
import DropdownButtons from "./DropdownButtons.vue"; |
117 |
import DropdownButtons from "./DropdownButtons.vue"; |
| 115 |
import TabsWrapper from "./TabsWrapper.vue"; |
118 |
import TabsWrapper from "./TabsWrapper.vue"; |
| 116 |
import AccordionWrapper from "./AccordionWrapper.vue"; |
119 |
import AccordionWrapper from "./AccordionWrapper.vue"; |
| 117 |
import { $__ } from "@koha-vue/i18n" |
120 |
import { $__ } from "@koha-vue/i18n"; |
| 118 |
|
121 |
|
| 119 |
export default { |
122 |
export default { |
| 120 |
inheritAttrs: false, |
123 |
inheritAttrs: false, |
|
Lines 122-128
export default {
Link Here
|
| 122 |
const initialized = ref(false); |
125 |
const initialized = ref(false); |
| 123 |
const resource = ref(null); |
126 |
const resource = ref(null); |
| 124 |
const editMode = ref(false); |
127 |
const editMode = ref(false); |
| 125 |
const buttonTextLeader = computed(() => editMode.value ? $__("Save") : $__("Submit")) |
|
|
| 126 |
|
128 |
|
| 127 |
const resourceToSave = computed(() => { |
129 |
const resourceToSave = computed(() => { |
| 128 |
return ( |
130 |
return ( |
|
Lines 145-151
export default {
Link Here
|
| 145 |
props.instancedResource.idAttr |
147 |
props.instancedResource.idAttr |
| 146 |
] |
148 |
] |
| 147 |
) { |
149 |
) { |
| 148 |
editMode.value = true |
150 |
editMode.value = true; |
| 149 |
props.instancedResource.getResource( |
151 |
props.instancedResource.getResource( |
| 150 |
props.instancedResource.route.params[ |
152 |
props.instancedResource.route.params[ |
| 151 |
props.instancedResource.idAttr |
153 |
props.instancedResource.idAttr |
|
Lines 163-222
export default {
Link Here
|
| 163 |
}); |
165 |
}); |
| 164 |
|
166 |
|
| 165 |
const saveAndNavigate = ($event, resourceToSave) => { |
167 |
const saveAndNavigate = ($event, resourceToSave) => { |
| 166 |
const { components, navigationOnFormSave, onFormSave, router, idAttr } = props.instancedResource |
168 |
const { |
|
|
169 |
components, |
| 170 |
navigationOnFormSave, |
| 171 |
onFormSave, |
| 172 |
router, |
| 173 |
idAttr, |
| 174 |
} = props.instancedResource; |
| 167 |
// Default to show |
175 |
// Default to show |
| 168 |
const navigationAction = saveOptionSelected.value || navigationOnFormSave || components.show |
176 |
const navigationAction = |
| 169 |
const idParamRequired = navigationAction === components.show || navigationAction === components.edit |
177 |
saveOptionSelected.value || |
|
|
178 |
navigationOnFormSave || |
| 179 |
components.show; |
| 180 |
const idParamRequired = |
| 181 |
navigationAction === components.show || |
| 182 |
navigationAction === components.edit; |
| 170 |
onFormSave($event, resourceToSave).then(resource => { |
183 |
onFormSave($event, resourceToSave).then(resource => { |
| 171 |
if(resource) { |
184 |
if (resource) { |
| 172 |
router.push({ |
185 |
router.push({ |
| 173 |
name: navigationAction, |
186 |
name: navigationAction, |
| 174 |
...(idParamRequired && { |
187 |
...(idParamRequired && { |
| 175 |
params: { |
188 |
params: { |
| 176 |
[idAttr]: resource[idAttr] |
189 |
[idAttr]: resource[idAttr], |
| 177 |
} |
190 |
}, |
| 178 |
}) |
191 |
}), |
| 179 |
}) |
192 |
}); |
| 180 |
} |
193 |
} |
| 181 |
}) |
194 |
}); |
| 182 |
} |
195 |
}; |
| 183 |
|
196 |
|
| 184 |
const saveOptionSelected = ref(props.instancedResource.navigationOnFormSave) |
197 |
const saveOptionSelected = ref( |
|
|
198 |
props.instancedResource.navigationOnFormSave |
| 199 |
); |
| 185 |
const dropdownButtons = computed(() => { |
200 |
const dropdownButtons = computed(() => { |
| 186 |
const { components, navigationOnFormSave } = props.instancedResource |
201 |
const { components, navigationOnFormSave } = |
|
|
202 |
props.instancedResource; |
| 187 |
|
203 |
|
| 188 |
const buttonOptions = { |
204 |
const buttonOptions = { |
| 189 |
list: { |
205 |
list: { |
| 190 |
title: $__("%s and return to list").format(buttonTextLeader.value), |
206 |
title: $__("Save and return to list"), |
| 191 |
action: "submit", |
207 |
action: "submit", |
| 192 |
cssClass: "btn btn-default", |
208 |
cssClass: "btn btn-default", |
| 193 |
callback: () => { |
209 |
callback: () => { |
| 194 |
saveOptionSelected.value = components.list |
210 |
saveOptionSelected.value = components.list; |
| 195 |
} |
211 |
}, |
| 196 |
}, |
212 |
}, |
| 197 |
show: { |
213 |
show: { |
| 198 |
title: $__("%s and show").format(buttonTextLeader.value), |
214 |
title: $__("Save and show"), |
| 199 |
action: "submit", |
215 |
action: "submit", |
| 200 |
cssClass: "btn btn-default", |
216 |
cssClass: "btn btn-default", |
| 201 |
callback: () => { |
217 |
callback: () => { |
| 202 |
saveOptionSelected.value = components.show |
218 |
saveOptionSelected.value = components.show; |
| 203 |
} |
219 |
}, |
| 204 |
}, |
220 |
}, |
| 205 |
edit: { |
221 |
edit: { |
| 206 |
title: $__("%s and continue editing").format(buttonTextLeader.value), |
222 |
title: $__("Save and continue editing"), |
| 207 |
action: "submit", |
223 |
action: "submit", |
| 208 |
cssClass: "btn btn-default", |
224 |
cssClass: "btn btn-default", |
| 209 |
callback: () => { |
225 |
callback: () => { |
| 210 |
saveOptionSelected.value = components.edit |
226 |
saveOptionSelected.value = components.edit; |
| 211 |
} |
227 |
}, |
| 212 |
} |
228 |
}, |
| 213 |
} |
229 |
}; |
| 214 |
return Object.keys(buttonOptions).reduce((acc, key) => { |
230 |
return Object.keys(buttonOptions).reduce((acc, key) => { |
| 215 |
if(key === "show" && !navigationOnFormSave) return acc |
231 |
if (key === "show" && !navigationOnFormSave) return acc; |
| 216 |
if(components[key] === navigationOnFormSave) return acc |
232 |
if (components[key] === navigationOnFormSave) return acc; |
| 217 |
return [buttonOptions[key], ...acc] |
233 |
return [buttonOptions[key], ...acc]; |
| 218 |
},[]) |
234 |
}, []); |
| 219 |
}) |
235 |
}); |
| 220 |
|
236 |
|
| 221 |
return { |
237 |
return { |
| 222 |
initialized, |
238 |
initialized, |
|
Lines 226-232
export default {
Link Here
|
| 226 |
saveAndNavigate, |
242 |
saveAndNavigate, |
| 227 |
editMode, |
243 |
editMode, |
| 228 |
dropdownButtons, |
244 |
dropdownButtons, |
| 229 |
buttonTextLeader |
|
|
| 230 |
}; |
245 |
}; |
| 231 |
}, |
246 |
}, |
| 232 |
props: { |
247 |
props: { |
|
Lines 237-243
export default {
Link Here
|
| 237 |
FormElement, |
252 |
FormElement, |
| 238 |
TabsWrapper, |
253 |
TabsWrapper, |
| 239 |
AccordionWrapper, |
254 |
AccordionWrapper, |
| 240 |
DropdownButtons |
255 |
DropdownButtons, |
| 241 |
}, |
256 |
}, |
| 242 |
name: "ResourceFormSave", |
257 |
name: "ResourceFormSave", |
| 243 |
}; |
258 |
}; |
| 244 |
- |
|
|