210210 <TemplateVaults
211211 v-if =" needField('vault')"
212212 :project-id =" this.projectId"
213- :vaults =" item. vaults"
213+ :vaults =" vaults"
214214 @change =" setTemplateVaults"
215215 ></TemplateVaults >
216216
217- <SurveyVars style =" margin-top : -10px ;" :vars =" item.survey_vars" @change =" setSurveyVars" />
217+ <SurveyVars
218+ style =" margin-top : -10px ;"
219+ :vars =" surveyVars"
220+ @change =" setSurveyVars"
221+ />
218222
219223 <v-select
220224 v-model =" item.view_id"
@@ -389,6 +393,19 @@ export default {
389393 },
390394
391395 computed: {
396+ surveyVars () {
397+ if (! this .item .survey_vars ) {
398+ throw new Error ();
399+ }
400+ return this .item .survey_vars ;
401+ },
402+
403+ vaults () {
404+ if (! this .item .vaults ) {
405+ throw new Error ();
406+ }
407+ return this .item .vaults ;
408+ },
392409
393410 isLoaded () {
394411 if (this .isNew && this .sourceItemId == null ) {
@@ -425,16 +442,16 @@ export default {
425442
426443 async afterLoadData () {
427444 if (this .sourceItemId ) {
428- this . item = (await axios ({
445+ const item = (await axios ({
429446 url: ` /api/project/${ this .projectId } /templates/${ this .sourceItemId } ` ,
430447 responseType: ' json' ,
431448 })).data ;
432449
433- this . item .id = null ;
450+ item .id = null ;
434451
435- if (this . item .vaults ) {
436- for (let i = 0 ; i < this . item .vaults .length ; i += 1 ) {
437- this . item .vaults [i].id = null ;
452+ if (item .vaults ) {
453+ for (let i = 0 ; i < item .vaults .length ; i += 1 ) {
454+ item .vaults [i].id = null ;
438455 }
439456 }
440457
@@ -448,6 +465,8 @@ export default {
448465 this .cronRepositoryId = sourceSchedule .repository_id ;
449466 this .cronVisible = this .cronRepositoryId != null ;
450467 }
468+
469+ this .item = item;
451470 }
452471
453472 this .advancedOptions = this .item .arguments != null || this .item .allow_override_args_in_task ;
0 commit comments