9191 :assetId =" assetId"
9292 :assetName =" assetName"
9393 />
94+ <b-modal ref =" duplicateScriptModalRef" :title =" $t('Copy Script')" centered header-close-content =" × ; " >
95+ <form >
96+ <div class =" form-group" >
97+ <label for =" dup-script-title" >{{ $t('Name') }}<small class =" ml-1" >*</small ></label >
98+ <input
99+ id =" dup-script-title"
100+ type =" text"
101+ class =" form-control"
102+ v-model =" dupScript.title"
103+ v-bind:class =" { 'is-invalid': errors.title }"
104+ />
105+ <div class =" invalid-feedback" role =" alert" v-if =" errors.title" >{{ errors.title[0] }}</div >
106+ </div >
107+ <div class =" form-group" >
108+ <category-select
109+ :label =" $t('Category')"
110+ api-get =" script_categories"
111+ api-list =" script_categories"
112+ v-model =" dupScript.script_category_id"
113+ :errors =" errors.script_category_id"
114+ />
115+ </div >
116+ <div class =" form-group" >
117+ <label for =" dup-script-description" >{{ $t('Description') }}</label >
118+ <textarea id =" dup-script-description" class =" form-control" rows =" 3" v-model =" dupScript.description" />
119+ </div >
120+ </form >
121+ <div slot =" modal-footer" class =" w-100 text-right" >
122+ <button type =" button" class =" btn btn-outline-secondary" @click =" hideDuplicateScriptModal" >{{ $t('Cancel') }}</button >
123+ <button type =" button" @click =" onSubmitDuplicateScript" class =" btn btn-secondary ml-2" >{{ $t('Save') }}</button >
124+ </div >
125+ </b-modal >
94126 </div >
95127 </div >
96128 </div >
@@ -112,6 +144,7 @@ import AddToProjectModal from "../../components/shared/AddToProjectModal.vue";
112144import CreateTemplateModal from " ../../components/templates/CreateTemplateModal.vue" ;
113145import CreatePmBlockModal from " ../../components/pm-blocks/CreatePmBlockModal.vue" ;
114146import EllipsisMenu from " ../../components/shared/EllipsisMenu.vue" ;
147+ import CategorySelect from " ../categories/components/CategorySelect.vue" ;
115148
116149const uniqIdsMixin = createUniqIdsMixin ();
117150
@@ -121,6 +154,7 @@ export default {
121154 CreateTemplateModal,
122155 CreatePmBlockModal,
123156 EllipsisMenu,
157+ CategorySelect,
124158 },
125159 mixins: [
126160 datatableMixin,
@@ -320,6 +354,29 @@ export default {
320354 this .pmBlockName = name;
321355 this .$refs [" create-pm-block-modal" ].show ();
322356 },
357+ /**
358+ * Open the duplicate script modal (required by scriptNavigation mixin for "Copy").
359+ */
360+ showModal () {
361+ this .$refs .duplicateScriptModalRef .show ();
362+ },
363+ hideDuplicateScriptModal () {
364+ this .$refs .duplicateScriptModalRef .hide ();
365+ },
366+ onSubmitDuplicateScript () {
367+ window .ProcessMaker .apiClient
368+ .put (" scripts/" + this .dupScript .id + " /duplicate" , this .dupScript )
369+ .then (() => {
370+ ProcessMaker .alert (this .$t (" The script was duplicated." ), " success" );
371+ this .hideDuplicateScriptModal ();
372+ this .fetch ();
373+ })
374+ .catch ((error ) => {
375+ if (error .response ? .status === 422 && error .response ? .data ? .errors ) {
376+ this .errors = error .response .data .errors ;
377+ }
378+ });
379+ },
323380 },
324381};
325382< / script>
0 commit comments