|
| 1 | +<template> |
| 2 | + <div class="data-table"> |
| 3 | + <data-loading |
| 4 | + :for="/screens/" |
| 5 | + v-show="shouldShowLoader" |
| 6 | + :empty="$t('No Data Available')" |
| 7 | + :empty-desc="$t('')" |
| 8 | + empty-icon="noData" |
| 9 | + /> |
| 10 | + <div v-show="!shouldShowLoader" class="card card-body my-templates-table-card" data-cy="my-templates-table"> |
| 11 | + <filter-table |
| 12 | + :headers="fields" |
| 13 | + :data="data" |
| 14 | + table-name="my-screen-templates" |
| 15 | + style="height: calc(100vh - 355px);" |
| 16 | + > |
| 17 | + <!-- Slot Table Header filter Button --> |
| 18 | + <template |
| 19 | + v-for="(column, index) in fields" |
| 20 | + #[`filter-${column.field}`] |
| 21 | + > |
| 22 | + <div |
| 23 | + v-if="column.sortable" |
| 24 | + :key="index" |
| 25 | + @click="handleEllipsisClick(column)" |
| 26 | + > |
| 27 | + <i |
| 28 | + :class="['fas', { |
| 29 | + 'fa-sort': column.direction === 'none', |
| 30 | + 'fa-sort-up': column.direction === 'asc', |
| 31 | + 'fa-sort-down': column.direction === 'desc', |
| 32 | + }]" |
| 33 | + /> |
| 34 | + </div> |
| 35 | + </template> |
| 36 | + <!-- Slot Table Body --> |
| 37 | + <template |
| 38 | + v-for="(row, rowIndex) in data.data" |
| 39 | + #[`row-${rowIndex}`] |
| 40 | + > |
| 41 | + <td |
| 42 | + v-for="(header, colIndex) in fields" |
| 43 | + :key="`${rowIndex}_${colIndex}`" |
| 44 | + :data-cy="`my-templates-table-td-${rowIndex}-${colIndex}`" |
| 45 | + > |
| 46 | + <div |
| 47 | + v-if="containsHTML(row[header.field])" |
| 48 | + :data-cy="`my-templates-table-html-${rowIndex}-${colIndex}`" |
| 49 | + v-html="sanitize(row[header.field])" |
| 50 | + /> |
| 51 | + <template v-else> |
| 52 | + <template |
| 53 | + v-if="isComponent(row[header.field])" |
| 54 | + :data-cy="`my-templates-table-component-${rowIndex}-${colIndex}`" |
| 55 | + > |
| 56 | + <component |
| 57 | + :is="row[header.field].component" |
| 58 | + v-bind="row[header.field].props" |
| 59 | + /> |
| 60 | + </template> |
| 61 | + <template |
| 62 | + v-else |
| 63 | + :data-cy="`my-templates-table-field-${rowIndex}-${colIndex}`" |
| 64 | + > |
| 65 | + <template v-if="header.field === 'name'"> |
| 66 | + <b-tooltip |
| 67 | + v-if="header.truncate" |
| 68 | + :target="`element-${row.id}`" |
| 69 | + custom-class="pm-table-tooltip" |
| 70 | + > |
| 71 | + {{ row[header.field] }} |
| 72 | + </b-tooltip> |
| 73 | + </template> |
| 74 | + <template v-if="header.field === 'actions'"> |
| 75 | + <ellipsis-menu |
| 76 | + class="my-template-table" |
| 77 | + :actions="myTemplateActions" |
| 78 | + :permission="permission" |
| 79 | + :data="row" |
| 80 | + :divider="true" |
| 81 | + :screen-template="true" |
| 82 | + @navigate="onMyTemplateNavigate" |
| 83 | + /> |
| 84 | + </template> |
| 85 | + <template v-if="header.field !== 'name'"> |
| 86 | + <div |
| 87 | + :style="{ maxWidth: header.width + 'px' }" |
| 88 | + > |
| 89 | + {{ getNestedPropertyValue(row, header) }} |
| 90 | + </div> |
| 91 | + </template> |
| 92 | + </template> |
| 93 | + </template> |
| 94 | + </td> |
| 95 | + </template> |
| 96 | + </filter-table> |
| 97 | + |
| 98 | + <pagination-table |
| 99 | + :meta="data.meta" |
| 100 | + data-cy="my-templates-pagination" |
| 101 | + @page-change="changePage" |
| 102 | + /> |
| 103 | + <pagination |
| 104 | + ref="pagination" |
| 105 | + :single="$t('Template')" |
| 106 | + :plural="$t('Templates')" |
| 107 | + :per-page-select-enabled="true" |
| 108 | + @changePerPage="changePerPage" |
| 109 | + @vuetable-pagination:change-page="onPageChange" |
| 110 | + /> |
| 111 | + </div> |
| 112 | + </div> |
| 113 | + </template> |
| 114 | + |
| 115 | + <script> |
| 116 | + import datatableMixin from "../../../components/common/mixins/datatable"; |
| 117 | + import dataLoadingMixin from "../../../components/common/mixins/apiDataLoading"; |
| 118 | + import ellipsisMenuMixin from "../../../components/shared/ellipsisMenuActions"; |
| 119 | + import screenNavigationMixin from "../../../components/shared/screenNavigation"; |
| 120 | + import EllipsisMenu from "../../../components/shared/EllipsisMenu.vue"; |
| 121 | + import FilterTableBodyMixin from "../../../components/shared/FilterTableBodyMixin"; |
| 122 | + import paginationTable from "../../../components/shared/PaginationTable.vue"; |
| 123 | +
|
| 124 | + import { createUniqIdsMixin } from "vue-uniq-ids"; |
| 125 | + const uniqIdsMixin = createUniqIdsMixin(); |
| 126 | + |
| 127 | + export default { |
| 128 | + components: { EllipsisMenu, paginationTable }, |
| 129 | + mixins: [datatableMixin, dataLoadingMixin, uniqIdsMixin, ellipsisMenuMixin, screenNavigationMixin, FilterTableBodyMixin], |
| 130 | + props: ["filter", "id", "permission"], |
| 131 | + data() { |
| 132 | + return { |
| 133 | + orderBy: "title", |
| 134 | + screenId: null, |
| 135 | + assetName: " ", |
| 136 | + assignedProjects: [], |
| 137 | + sortOrder: [ |
| 138 | + { |
| 139 | + field: "title", |
| 140 | + sortField: "title", |
| 141 | + direction: "asc" |
| 142 | + } |
| 143 | + ], |
| 144 | + |
| 145 | + fields: [ |
| 146 | + { |
| 147 | + label: this.$t("Name"), |
| 148 | + field: "title", |
| 149 | + width: 200, |
| 150 | + sortable: true, |
| 151 | + truncate: true, |
| 152 | + direction: "none", |
| 153 | + }, |
| 154 | + { |
| 155 | + label: this.$t("Description"), |
| 156 | + field: "description", |
| 157 | + width: 200, |
| 158 | + sortable: true, |
| 159 | + direction: "none", |
| 160 | + sortField: "description", |
| 161 | + }, |
| 162 | + { |
| 163 | + label: this.$t("Type of Screen"), |
| 164 | + field: "screen_type", |
| 165 | + width: 160, |
| 166 | + sortable: true, |
| 167 | + direction: "none", |
| 168 | + sortField: "screen_type", |
| 169 | + }, |
| 170 | + { |
| 171 | + label: this.$t("Modified"), |
| 172 | + field: "updated_at", |
| 173 | + format: "datetime", |
| 174 | + width: 160, |
| 175 | + sortable: true, |
| 176 | + direction: "none", |
| 177 | + }, |
| 178 | + { |
| 179 | + name: "__slot:actions", |
| 180 | + field: "actions", |
| 181 | + width: 60, |
| 182 | + } |
| 183 | + ] |
| 184 | + }; |
| 185 | + }, |
| 186 | + |
| 187 | + methods: { |
| 188 | + onMyTemplateNavigate() { |
| 189 | + console.log('ellipsis menu action'); |
| 190 | + }, |
| 191 | + fetch() { |
| 192 | + //TODO: UPDATE FUNCTIONALITY FOR FETCHING 'MY TEMPLATES' FROM SCREEN TEMPLATES |
| 193 | + this.loading = true; |
| 194 | + //change method sort by slot name |
| 195 | + this.orderBy = this.orderBy === "__slot:title" ? "title" : this.orderBy; |
| 196 | + // Load from our api client |
| 197 | + ProcessMaker.apiClient |
| 198 | + .get( |
| 199 | + "screens" + |
| 200 | + "?page=" + |
| 201 | + this.page + |
| 202 | + "&per_page=" + |
| 203 | + this.perPage + |
| 204 | + "&filter=" + |
| 205 | + this.filter + |
| 206 | + "&order_by=" + |
| 207 | + this.orderBy + |
| 208 | + "&order_direction=" + |
| 209 | + this.orderDirection + |
| 210 | + "&include=categories,category" + |
| 211 | + "&exclude=config" |
| 212 | + ) |
| 213 | + .then(response => { |
| 214 | + this.data = this.transform(response.data); |
| 215 | + this.loading = false; |
| 216 | + }); |
| 217 | + }, |
| 218 | + }, |
| 219 | + }; |
| 220 | + </script> |
| 221 | + |
| 222 | +<style lang="scss" scoped> |
| 223 | +:deep(th#_description) { |
| 224 | + width: 250px; |
| 225 | +} |
| 226 | +
|
| 227 | +.my-templates-table-card { |
| 228 | + padding: 0; |
| 229 | +} |
| 230 | +</style> |
0 commit comments