fix col order reset button, show only if order is changed

pull/35/head
Ondřej Hruška 6 years ago
parent 58c28b776b
commit 70cff26719
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 2
      app/Http/Controllers/TableEditController.php
  2. 9
      resources/assets/js/components/ColumnEditor.vue

@ -262,6 +262,7 @@ class TableEditController extends Controller
case 'col.sort': case 'col.sort':
$changeset->setColOrder($input->order); $changeset->setColOrder($input->order);
$resp = !empty($changeset->columnOrder); // return flag if order is changed
break; break;
case 'note.set': case 'note.set':
@ -270,6 +271,7 @@ class TableEditController extends Controller
case 'reset.col-order': // called via POST or GET case 'reset.col-order': // called via POST or GET
$changeset->resetColumnOrder(); $changeset->resetColumnOrder();
$resp = $changeset->fetchAndTransformColumns(); // return all columns
break; break;
case 'reset.col-remove': // called via GET case 'reset.col-remove': // called via GET

@ -20,7 +20,7 @@ Complex animated column editor for the table edit page
<th :style="tdWidthStyle('type')">Type</th> <th :style="tdWidthStyle('type')">Type</th>
<th :style="tdWidthStyle('title')">Title</th> <th :style="tdWidthStyle('title')">Title</th>
<th> <th>
<a href="" type="button" v-if="!newTable" <a href="" type="button" v-if="!newTable && orderChanged"
@click.prevent="resetOrder()" @click.prevent="resetOrder()"
class="text-danger no-decoration"> class="text-danger no-decoration">
Reset Order Reset Order
@ -205,10 +205,12 @@ export default {
newTable: { type: Boolean, default: false }, newTable: { type: Boolean, default: false },
name: { type: String, required: true }, name: { type: String, required: true },
xColumns: { type: Array, required: true }, xColumns: { type: Array, required: true },
orderChanged: { type: Boolean, default: false },
}, },
data () { data () {
return { return {
newColNum: 0, newColNum: 0,
orderChanged: this.orderChanged,
columns: this.xColumns, columns: this.xColumns,
colTypes: ['string', 'int', 'float', 'bool'], colTypes: ['string', 'int', 'float', 'bool'],
debouncedSortUpdate: _.debounce(() => this.submitColOrder(), 350) debouncedSortUpdate: _.debounce(() => this.submitColOrder(), 350)
@ -225,6 +227,8 @@ export default {
this.query ({ this.query ({
action: 'col.sort', action: 'col.sort',
order: ids, order: ids,
}, (resp) => {
this.orderChanged = resp.data;
}) })
}, },
@ -417,7 +421,8 @@ export default {
this.query({ this.query({
action: 'reset.col-order' action: 'reset.col-order'
}, (resp) => { }, (resp) => {
this.columns = resp.data; this.columns = resp.data
this.orderChanged = false
}) })
} }
} }

Loading…
Cancel
Save