add possibility to align table-column-text, fix row actions styling

This commit is contained in:
Anton Schubert 2017-08-30 02:00:03 +02:00
parent 8045a3d3cf
commit c66ff6f938
4 changed files with 75 additions and 75 deletions

View File

@ -1,45 +1,50 @@
<template> <template>
<div class="cms_table"> <div class="cms_table">
<!-- Header -->
<div class="table_header"> <div class="table_header">
<!-- <div class="table_row"> --> <div v-for="(col, i) in columns"
<div v-for="(col, i) in columns" :class="['table_cell', {['sortable']: col.orderBy, [`align-${col.align}`]: col.align}]"
:class="['table_cell', {['sortable']: col.orderBy}]" :key="i">
:key="i">
<div @click="orderBy(col.orderBy)" v-if="col.orderBy"> <!-- Column with sorting -->
{{ col.heading }} <div @click="orderBy(col.orderBy)" v-if="col.orderBy">
<i class="icon icon-angle-up" aria-hidden="true" v-if="currentOrderBy !== col.orderBy"></i> {{ col.heading }}
<i class="icon icon-angle-circled-down" aria-hidden="true" v-else-if="currentOrderDesc"></i>
<i class="icon icon-angle-circled-up" aria-hidden="true" v-else></i> <i class="icon icon-angle-up" aria-hidden="true" v-if="currentOrderBy !== col.orderBy"></i>
</div> <i class="icon icon-angle-circled-down" aria-hidden="true" v-else-if="currentOrderDesc"></i>
<div v-else>{{ col.heading }}</div> <i class="icon icon-angle-circled-up" aria-hidden="true" v-else></i>
</div> </div>
<div class="table_cell cell_settings" v-if="actions.length"></div>
<!-- </div> --> <!-- Column without sorting -->
<div v-else>{{ col.heading }}</div>
</div>
<div class="table_cell cell_settings" v-if="actions.length"></div>
</div> </div>
<!-- Content -->
<div class="table_content" is="transition-group" name="list"> <div class="table_content" is="transition-group" name="list">
<div class="table_row" v-for="(row, ri) in rows" :key="ri"> <div class="table_row" v-for="(row, ri) in rows" :key="ri">
<div class="table_cell" v-for="(col, ci) in columns" :key="ci + 'c'">
<span v-if="col.prop">{{ getProp(row, col.prop) }}</span> <!-- Row content -->
<div v-for="(col, ci) in columns"
:class="['table_cell', {[`align-${col.align}`]: col.align}]"
:key="ci + 'c'">
<span v-if="col.prop" :title="getProp(row, col.prop)">{{ getProp(row, col.prop) }}</span>
<span v-else-if="col.render">{{ col.render(row) }}</span> <span v-else-if="col.render">{{ col.render(row) }}</span>
</div> </div>
<!-- Row actions -->
<div class="table_cell cell_settings" v-if="actions.length" ref="row_actions"> <div class="table_cell cell_settings" v-if="actions.length" ref="row_actions">
<div title="Open actions" class="actions_btn" @click="openActions">
<i class="icon icon-cog" aria-hidden="true"></i>
</div>
<ul class="actions_container"> <ul class="actions_container">
<li v-for="(a, i) in actions"> <li v-for="(a, i) in actions" :title="a.title" @click="a.action(row)">
<div :title="a.title" @click="a.action(row)"> <i :class="['icon', a.icon]"></i>
<i :class="['icon', a.icon]"></i>
</div>
</li>
<li>
<div title="Close actions" @click="closeActions">
<i class="icon icon-cog"></i>
</div>
</li> </li>
</ul> </ul>
<div title="Open actions" class="actions_btn" @click="toggleActions">
<i class="icon icon-cog" aria-hidden="true"></i>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -97,17 +102,13 @@
}); });
return val; return val;
}, },
openActions(event) { toggleActions(event) {
const parent = event.currentTarget.parentNode; const parent = event.currentTarget.parentNode;
this.$refs.row_actions.forEach((item) => { this.$refs.row_actions.forEach((item) => {
if (item !== parent) if (item !== parent)
item.classList.remove("open") item.classList.remove("open")
}); });
parent.classList.add("open"); parent.classList.toggle("open");
},
closeActions(event) {
const parent = event.currentTarget.parentNode.parentNode.parentNode;
parent.classList.remove("open");
} }
} }
} }
@ -115,6 +116,7 @@
<style lang="less"> <style lang="less">
@import "../mixins"; @import "../mixins";
.list-item { .list-item {
display: inline-block; display: inline-block;
margin-right: 10px; margin-right: 10px;
@ -166,19 +168,19 @@
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
&.sortable{ &.sortable:hover{cursor: pointer;}
&:hover{
cursor: pointer; &.align-center{text-align: center;}
} &.align-left{text-align: left;}
} &.align-right{text-align: right;}
} }
/*.cell_checkbox {width:40px;}
.cell_image {width:120px; line-height:0;} .cell_image img {width:100%;}
.cell_title {position:relative;}
.cell_title a {color:#000;} .cell_title a:hover {color:#28b78d;}*/
/* === Other cell types === */ /* === Other cell types === */
/*.cell_checkbox {width:40px;}
.cell_image {width:120px; line-height:0;} .cell_image img {width:100%;}
.cell_title {position:relative;}
.cell_title a {color:#000;} .cell_title a:hover {color:#28b78d;}*/
/*.cell_date {} /*.cell_date {}
.cell_author {} .cell_author {}
.cell_category {} .cell_category {}
@ -205,11 +207,16 @@
.cell_settings { .cell_settings {
.clearfix(); .clearfix();
position: relative; position: relative;
width: 40px; width: 22.4px + 2*15px;
text-align: right; text-align: right;
overflow: visible; overflow: visible;
.icon {
font-size: 16px;
}
.actions_btn{ .actions_btn{
position: relative;
z-index: 20; z-index: 20;
&:hover{ &:hover{
cursor: pointer; cursor: pointer;
@ -217,53 +224,45 @@
} }
} }
.icon {
font-size: 16px;
}
.actions_container { .actions_container {
position: absolute; position: absolute;
z-index: -1;
top: -5px;
right: 0;
padding: 5px 10px; padding: 5px 10px;
top: 50%;
margin-top: -16px;
right: 7px;
opacity: 0; opacity: 0;
overflow: hidden; pointer-events: none;
transition: opacity 0.3s;
color: white;
background: @cms_brand_primary;
border-radius: 20px; border-radius: 20px;
background: @cms_bg_lighter;
transition: all 0.3s;
white-space: nowrap;
li { li {
display: inline-block; display: inline-block;
padding-right: 5px;
&:last-child{ &:last-child{
border-left: 1px solid @text_color; border-right: 1px solid white;
padding-left: 5px; padding-right: 10px;
margin-right: 26px;
.icon:before{ .icon:before{
margin-right: 0; margin-right: 0;
} }
} }
} }
li+li{ .icon:hover{
margin-left: 5px; cursor: pointer;
}
.icon {
color: @text_color; color: @text_color;
&:hover{
cursor: pointer;
color: @cms_brand_primary;
}
} }
} }
&.open { &.open {
.actions_container{ .actions_btn {color: white; &:hover{color: black;}}
.actions_container {
z-index: 10;
opacity: 1; opacity: 1;
z-index: 1;
transition: all 0.3s;
} }
} }
} }

View File

@ -5,9 +5,10 @@
@text_color: black; @text_color: black;
@gray_dark: #152129;
@cms_bg_lighter: #e0e0e0; @cms_bg_lighter: #e0e0e0;
@cms_bg_light: #1a2e3b; @cms_bg_light: #1a2e3b;
@cms_dark_border: #152129;
@cms_brand_primary: #28b78d; @cms_brand_primary: #28b78d;
@cms_brand_secondary: #152129; @cms_brand_secondary: #152129;

View File

@ -151,7 +151,7 @@ export default {
border-color: transparent; border-color: transparent;
&:focus { &:focus {
border: solid 1px @cms_dark_border; border: solid 1px @gray_dark;
background: white; background: white;
} }
} }

View File

@ -38,12 +38,12 @@ export default {
heading: 'ID', heading: 'ID',
prop: 'ID', prop: 'ID',
orderBy: 'id', orderBy: 'id',
align: 'left' align: 'right'
}, { }, {
heading: 'Benutzername', heading: 'Benutzername',
prop: 'Username', prop: 'Username',
orderBy: 'username', orderBy: 'username',
align: 'center' align: 'left'
}, { }, {
heading: 'Firma', heading: 'Firma',
prop: 'Company', prop: 'Company',