1919 <div >
2020 <a-card class =" breadcrumb-card" >
2121 <a-row >
22- <a-col :span =" 14 " style =" padding-left : 6px " >
22+ <a-col :span =" 12 " style =" padding-left : 6px " >
2323 <breadcrumb :resource =" resource" >
2424 <a-tooltip placement =" bottom" slot =" end" >
2525 <template slot="title">
3737 </a-tooltip >
3838 </breadcrumb >
3939 </a-col >
40- <a-col :span =" 10 " >
40+ <a-col :span =" 12 " >
4141 <span style =" float : right " >
4242 <action-button
4343 style =" margin-bottom : 5px "
4747 :dataView =" dataView"
4848 :resource =" resource"
4949 @exec-action =" execAction" />
50+ <a-select
51+ v-if =" filters && filters.length > 0"
52+ placeholder =" Filter By"
53+ :value =" $t(selectedFilter)"
54+ style =" min-width : 100px ; margin-left : 10px "
55+ @change =" changeFilter" >
56+ <a-icon slot =" suffixIcon" type =" filter" />
57+ <a-select-option v-for =" filter in filters" :key =" filter" >
58+ {{ $t(filter) }}
59+ </a-select-option >
60+ </a-select >
5061 <a-input-search
5162 style =" width : 20vw ; margin-left : 10px "
5263 placeholder =" Search"
@@ -305,6 +316,8 @@ export default {
305316 showAction: false ,
306317 dataView: false ,
307318 treeView: false ,
319+ selectedFilter: ' ' ,
320+ filters: [],
308321 actions: [],
309322 treeData: [],
310323 treeSelected: {},
@@ -337,6 +350,7 @@ export default {
337350 this .searchQuery = ' '
338351 this .page = 1
339352 this .itemCount = 0
353+ this .selectedFilter = ' '
340354 this .fetchData ()
341355 }
342356 },
@@ -347,7 +361,7 @@ export default {
347361 }
348362 },
349363 methods: {
350- fetchData () {
364+ fetchData (params = { listall : true } ) {
351365 if (this .routeName !== this .$route .name ) {
352366 this .routeName = this .$route .name
353367 this .items = []
@@ -357,11 +371,12 @@ export default {
357371 }
358372 this .apiName = ' '
359373 this .actions = []
374+ this .filters = this .$route .meta .filters || []
360375 this .columns = []
361376 this .columnKeys = []
362377 this .treeData = []
363378 this .treeSelected = {}
364- var params = { listall : true }
379+
365380 if (Object .keys (this .$route .query ).length > 0 ) {
366381 Object .assign (params, this .$route .query )
367382 } else if (this .$route .meta .params ) {
@@ -393,6 +408,26 @@ export default {
393408 return
394409 }
395410
411+ if ([' listTemplates' , ' listIsos' ].includes (this .apiName ) && ! this .dataView ) {
412+ if ([' Admin' ].includes (this .$store .getters .userInfo .roletype )) {
413+ this .filters = [' all' , ... this .filters ]
414+ if (this .selectedFilter === ' ' ) {
415+ this .selectedFilter = ' all'
416+ }
417+ }
418+ if (this .selectedFilter === ' ' ) {
419+ this .selectedFilter = ' self'
420+ }
421+ }
422+
423+ if (this .selectedFilter && this .filters .length > 0 ) {
424+ if (this .$route .path .startsWith (' /template' )) {
425+ params .templatefilter = this .selectedFilter
426+ } else if (this .$route .path .startsWith (' /iso' )) {
427+ params .isofilter = this .selectedFilter
428+ }
429+ }
430+
396431 if (this .searchQuery !== ' ' ) {
397432 if (this .apiName === ' listRoles' ) {
398433 params .name = this .searchQuery
@@ -450,12 +485,6 @@ export default {
450485 delete params .treeView
451486 }
452487
453- if ([' listTemplates' , ' listIsos' ].includes (this .apiName ) && ! this .dataView ) {
454- if ([' Admin' ].includes (this .$store .getters .userInfo .roletype )) {
455- params .templatefilter = ' all'
456- }
457- }
458-
459488 api (this .apiName , params).then (json => {
460489 var responseName
461490 var objectName
@@ -524,6 +553,13 @@ export default {
524553 this .loading = false
525554 })
526555 },
556+ removeStringStartSubstringIfPresent (str , searchstr ) {
557+ var index = str .indexOf (searchstr)
558+ if (index !== 0 ) {
559+ return str
560+ }
561+ return str .slice (index + searchstr .length )
562+ },
527563 onSearch (value ) {
528564 this .searchQuery = value
529565 this .page = 1
@@ -576,7 +612,7 @@ export default {
576612 }
577613 }
578614 this .currentAction .loading = false
579- if (action .dataView && action . icon === ' edit' ) {
615+ if (action .dataView && [ ' copy ' , ' edit' ]. includes ( action . icon ) ) {
580616 this .fillEditFormFieldValues ()
581617 }
582618 },
@@ -585,8 +621,11 @@ export default {
585621 return
586622 }
587623 var paramName = param .name
624+ var extractedParamName = paramName .replace (' ids' , ' ' ).replace (' id' , ' ' ).toLowerCase ()
625+ extractedParamName = this .removeStringStartSubstringIfPresent (extractedParamName, ' source' )
626+ extractedParamName = this .removeStringStartSubstringIfPresent (extractedParamName, ' dest' )
588627 var params = { listall: true }
589- const possibleName = ' list' + paramName . replace ( ' ids ' , ' ' ). replace ( ' id ' , ' ' ). toLowerCase () + ' s'
628+ const possibleName = ' list' + extractedParamName + ' s'
590629 var possibleApi
591630 if (this .currentAction .mapping && param .name in this .currentAction .mapping && this .currentAction .mapping [param .name ].api ) {
592631 possibleApi = this .currentAction .mapping [param .name ].api
@@ -668,6 +707,7 @@ export default {
668707 let fieldName = null
669708 if (field .type === ' uuid' || field .type === ' list' || field .name === ' account' || (this .currentAction .mapping && field .name in this .currentAction .mapping )) {
670709 fieldName = field .name .replace (' ids' , ' name' ).replace (' id' , ' name' )
710+ fieldName = this .removeStringStartSubstringIfPresent (fieldName, ' source' )
671711 } else {
672712 fieldName = field .name
673713 }
@@ -774,6 +814,10 @@ export default {
774814 }
775815 })
776816 },
817+ changeFilter (filter ) {
818+ this .selectedFilter = filter
819+ this .fetchData ()
820+ },
777821 changePage (page , pageSize ) {
778822 this .page = page
779823 this .pageSize = pageSize
0 commit comments