|
2 | 2 | export default ({ |
3 | 3 | props: { |
4 | 4 | title: String, |
| 5 | + instructions: String, |
5 | 6 | action: String, |
6 | 7 | blueprint: Array, |
7 | 8 | meta: Array, |
8 | 9 | redirectTo: String, |
9 | 10 | values: Array, |
10 | 11 | data: Array, |
11 | 12 | items: Array, |
| 13 | + type: String, |
12 | 14 | }, |
13 | 15 | computed: { |
14 | 16 | lastPage() { |
@@ -81,6 +83,17 @@ export default ({ |
81 | 83 | }) |
82 | 84 | } |
83 | 85 | }, |
| 86 | + deleteQueryString(query_string) { |
| 87 | + if (confirm('Are you sure you want to delete this query string?')) { |
| 88 | + Statamic.$axios.post(cp_url('/alt-design/alt-redirect/query-strings/delete'), { |
| 89 | + query_string: query_string, |
| 90 | + }).then(res => { |
| 91 | + this.updateItems(res) |
| 92 | + }).catch(err => { |
| 93 | + console.log(err) |
| 94 | + }) |
| 95 | + } |
| 96 | + }, |
84 | 97 | importFromCSV() { |
85 | 98 | if (!this.selectedFile) { |
86 | 99 | alert("You haven't attached a CSV file!"); |
@@ -115,53 +128,84 @@ export default ({ |
115 | 128 | <template> |
116 | 129 | <div id="alt-redirect"> |
117 | 130 |
|
118 | | - <publish-form :title="title" :action="action" :blueprint="blueprint" :meta="meta" :values="values" @saved="updateItems($event)"></publish-form> |
| 131 | + <h1 class="flex-1">{{ title }}</h1> |
| 132 | + <h2 class="flex-1">{{ instructions }}</h2> |
| 133 | + |
| 134 | + <publish-form :title="''" :action="action" :blueprint="blueprint" :meta="meta" :values="values" @saved="updateItems($event)"></publish-form> |
119 | 135 |
|
120 | 136 | <div class="card overflow-hidden p-0"> |
121 | 137 | <div class="mt-4 pb-2 px-4"> |
122 | 138 | <input type="text" class="input-text" v-model="search" placeholder="Search"> |
123 | 139 | </div> |
124 | 140 | <div class="px-2"> |
125 | | - <table data-size="sm" tabindex="0" class="data-table" style="table-layout: fixed"> |
126 | | - <thead> |
| 141 | + <table v-if="type == 'redirects'" data-size="sm" tabindex="0" class="data-table" style="table-layout: fixed"> |
| 142 | + <thead> |
| 143 | + <tr> |
| 144 | + <th class="group from-column sortable-column" style="width:33%"> |
| 145 | + <span>From</span> |
| 146 | + </th> |
| 147 | + <th class="group from-column sortable-column pr-8 w-24" style="width:33%"> |
| 148 | + <span>To</span> |
| 149 | + </th> |
| 150 | + <th class="group to-column pr-8" style="width:8%"> |
| 151 | + <span>Type</span> |
| 152 | + </th> |
| 153 | + <th class="group to-column pr-8" style="width:15%"> |
| 154 | + <span>Sites</span> |
| 155 | + </th> |
| 156 | + <th class="actions-column" style="width:13.4%"></th> |
| 157 | + </tr> |
| 158 | + </thead> |
| 159 | + <tbody> |
| 160 | + <tr v-for="item in itemsSliced" :key="item.id" style="width : 100%; overflow: clip"> |
| 161 | + <td> |
| 162 | + {{ item.from }} |
| 163 | + </td> |
| 164 | + <td> |
| 165 | + {{ item.to }} |
| 166 | + </td> |
| 167 | + <td> |
| 168 | + {{ item.redirect_type }} |
| 169 | + </td> |
| 170 | + <td> |
| 171 | + {{ (item.sites && item.sites.length ) ? item.sites.join(', ') : "Unknown" }} |
| 172 | + </td> |
| 173 | + <td> |
| 174 | + <button @click="deleteRedirect(item.from, item.id)" class="btn" |
| 175 | + style="color: #bc2626;">Remove |
| 176 | + </button> |
| 177 | + </td> |
| 178 | + </tr> |
| 179 | + </tbody> |
| 180 | + </table> |
| 181 | + <table v-if="type == 'query-strings'" data-size="sm" tabindex="0" class="data-table" style="table-layout: fixed"> |
| 182 | + <thead> |
127 | 183 | <tr> |
128 | | - <th class="group from-column sortable-column" style="width:33%"> |
129 | | - <span>From</span> |
| 184 | + <th class="group from-column sortable-column" style="width:66%"> |
| 185 | + <span>Query String Key</span> |
130 | 186 | </th> |
131 | | - <th class="group from-column sortable-column pr-8 w-24" style="width:33%"> |
132 | | - <span>To</span> |
133 | | - </th> |
134 | | - <th class="group to-column pr-8" style="width:8%"> |
135 | | - <span>Type</span> |
136 | | - </th> |
137 | | - <th class="group to-column pr-8" style="width:15%"> |
| 187 | + <th class="group to-column pr-8" style="width:20.6%"> |
138 | 188 | <span>Sites</span> |
139 | 189 | </th> |
140 | 190 | <th class="actions-column" style="width:13.4%"></th> |
141 | 191 | </tr> |
142 | | - </thead> |
143 | | - <tbody> |
| 192 | + </thead> |
| 193 | + <tbody> |
144 | 194 | <tr v-for="item in itemsSliced" :key="item.id" style="width : 100%; overflow: clip"> |
145 | 195 | <td> |
146 | | - {{ item.from }} |
147 | | - </td> |
148 | | - <td> |
149 | | - {{ item.to }} |
150 | | - </td> |
151 | | - <td> |
152 | | - {{ item.redirect_type }} |
| 196 | + {{ item.query_string }} |
153 | 197 | </td> |
154 | 198 | <td> |
155 | 199 | {{ (item.sites && item.sites.length ) ? item.sites.join(', ') : "Unknown" }} |
156 | 200 | </td> |
157 | 201 | <td> |
158 | | - <button @click="deleteRedirect(item.from, item.id)" class="btn" |
| 202 | + <button @click="deleteQueryString(item.query_string)" class="btn" |
159 | 203 | style="color: #bc2626;">Remove |
160 | 204 | </button> |
161 | 205 | </td> |
162 | 206 | </tr> |
163 | | - </tbody> |
164 | | - </table> |
| 207 | + </tbody> |
| 208 | + </table> |
165 | 209 | </div> |
166 | 210 | <div class="pagination text-sm py-4 px-4 flex items-center justify-between"> |
167 | 211 | <div class="w-1/3 flex items-center"> |
@@ -213,8 +257,7 @@ export default ({ |
213 | 257 | </div> |
214 | 258 | </div> |
215 | 259 | </div> |
216 | | - |
217 | | - <div class="flex justify-between"> |
| 260 | + <div class="flex justify-between" :class="{ hidden: type == 'query-strings' }"> |
218 | 261 | <div class="w-full xl:w-1/2 card overflow-hidden p-0 mb-4 mt-4 mr-4 px-4 py-4"> |
219 | 262 | <span class="font-semibold mb-2">CSV Export</span><br> |
220 | 263 | <p class="text-sm mb-4">Exports CSV of all redirects, use this format on import.</p> |
|
0 commit comments