better table spacing, bugfix in axios query code

pull/35/head
Ondřej Hruška 6 years ago
parent 81261aba8b
commit e3a8616c68
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 29
      resources/assets/js/components/ColumnEditor.vue
  2. 14
      resources/assets/js/components/RowsEditor.vue
  3. 3
      resources/assets/js/components/table-editor-utils.js

@ -12,8 +12,6 @@ Complex animated column editor for the table edit page
<th :style="tdWidthStyle('name')">Name</th> <th :style="tdWidthStyle('name')">Name</th>
<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 v-if="!newTable"></th>
<th></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
@ -74,27 +72,22 @@ Complex animated column editor for the table edit page
</td> </td>
</template> </template>
<td v-if="!newTable"> <td class="text-nowrap"><!--
<!-- Save button --> Save button
<a href="" :class="['btn','btn-outline-secondary',{'disabled': col._remove}]" --><a href="" :class="['mr-1','btn','btn-outline-secondary',{'disabled': col._remove}]"
v-if="!newTable"
@click.prevent="toggleColEditing(col)"> @click.prevent="toggleColEditing(col)">
<v-icon :class="col._editing ? 'fa-save' : 'fa-pencil'" <v-icon :class="col._editing ? 'fa-save' : 'fa-pencil'"
:alt="col._editing ? 'Save' : 'Edit'" /> :alt="col._editing ? 'Save' : 'Edit'" />
</a> </a><!--
</td> Delete button
--><button type="button" :class="delBtnClass(col)"
<td>
<!-- Delete button -->
<button type="button" :class="delBtnClass(col)"
@click.prevent="toggleColDelete(col)"> @click.prevent="toggleColDelete(col)">
<v-icon :class="col._remove ? 'fa-undo' : 'fa-trash-o'" <v-icon :class="col._remove ? 'fa-undo' : 'fa-trash-o'"
:alt="col._remove ? 'Undo Remove' : 'Remove'" /> :alt="col._remove ? 'Undo Remove' : 'Remove'" />
</button> </button><!--
</td> Add button
--><button type="button" :class="['x-add-btn', 'btn', 'btn-outline-secondary']"
<td>
<!-- Add button -->
<button type="button" :class="['btn', 'btn-outline-secondary']"
v-if="i === columns.length - 1" v-if="i === columns.length - 1"
@click.prevent="addCol()"> @click.prevent="addCol()">
<v-icon class="fa-plus" alt="Add Column" /> <v-icon class="fa-plus" alt="Add Column" />
@ -151,6 +144,7 @@ Complex animated column editor for the table edit page
// approximate position of delete button // approximate position of delete button
clip-path: circle(calc(100% + 5em) at calc(100% - 4em) 50%); clip-path: circle(calc(100% + 5em) at calc(100% - 4em) 50%);
} }
.col-list-leave-active .delete-btn { .col-list-leave-active .delete-btn {
animation: col-list-leave-delete-btn .3s forwards; animation: col-list-leave-delete-btn .3s forwards;
} }
@ -312,6 +306,7 @@ export default {
/** Compute classes for the column's delete button */ /** Compute classes for the column's delete button */
delBtnClass(col) { delBtnClass(col) {
return [ return [
'mr-1',
'btn', 'btn',
'btn-outline-danger', 'btn-outline-danger',
'delete-btn', 'delete-btn',

@ -13,23 +13,20 @@ Rows are identified by row._id, columns by col.id
<table class="table table-hover table-sm table-fixed td-va-middle"> <table class="table table-hover table-sm table-fixed td-va-middle">
<thead> <thead>
<tr> <tr>
<th style="width:3rem"></th> <th style="width:6rem"></th>
<th style="width:3rem"></th>
<th v-for="col in columns" :class="colClasses(col)" :title="col.name">{{col.title}}</th> <th v-for="col in columns" :class="colClasses(col)" :title="col.name">{{col.title}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="row in rows" :style="rowStyle(row)"> <tr v-for="row in rows" :style="rowStyle(row)">
<td> <td>
<a href="" :class="['btn','btn-outline-danger',{'active': row._remove}]" <a href="" :class="['mr-1','btn','btn-outline-danger',{'active': row._remove}]"
@click.prevent="toggleRowDelete(row._id)"> @click.prevent="toggleRowDelete(row._id)">
<v-icon :class="row._remove ? 'fa-undo' : 'fa-trash-o'" <v-icon :class="row._remove ? 'fa-undo' : 'fa-trash-o'"
:alt="row._remove ? 'Undo Remove' : 'Remove'" /> :alt="row._remove ? 'Undo Remove' : 'Remove'" />
</a> </a><!--
</td> --><a href="" :class="['btn','btn-outline-secondary',{'disabled': row._remove}]"
<td> @click.prevent="toggleRowEditing(row._id)">
<a href="" :class="['btn','btn-outline-secondary',{'disabled': row._remove}]"
@click.prevent="toggleRowEditing(row._id)">
<v-icon :class="row._editing ? 'fa-save' : 'fa-pencil'" <v-icon :class="row._editing ? 'fa-save' : 'fa-pencil'"
:alt="row._editing ? 'Save' : 'Edit'" /> :alt="row._editing ? 'Save' : 'Edit'" />
</a> </a>
@ -53,7 +50,6 @@ Rows are identified by row._id, columns by col.id
alt="Revert Change" /> alt="Revert Change" />
</td> </td>
</template> </template>
</tr> </tr>
</tbody> </tbody>
</table> </table>

@ -5,7 +5,8 @@ function busy (yes) {
function query (route, data, sucfn, erfn) { function query (route, data, sucfn, erfn) {
busy(true) busy(true)
if (!sucfn) sucfn = () => {} if (!sucfn) sucfn = () => {}
if (!sucfn) erfn = () => {} if (!erfn) erfn = () => {}
window.axios.post(route, data).then(sucfn).catch((error) => { window.axios.post(route, data).then(sucfn).catch((error) => {
console.error(error.message) console.error(error.message)
erfn(error.response.data) erfn(error.response.data)

Loading…
Cancel
Save