Improve design sorting arrow

This commit is contained in:
Aurelsicoko 2017-09-20 13:19:36 +02:00
parent e64e5414ce
commit 6b83375009
4 changed files with 38 additions and 7 deletions

View File

@ -27,9 +27,9 @@ class TableHeader extends React.Component {
let icon;
if (this.props.sort === header.name) {
icon = <i className={`fa fa-sort-asc ${styles.icon}`} />;
icon = <i className={`fa fa-sort-asc ${styles.iconAsc}`} />;
} else if (this.props.sort === `-${header.name}`) {
icon = <i className={`fa fa-sort-desc ${styles.icon}`} />;
icon = <i className={`fa fa-sort-asc ${styles.iconDesc}`} />;
}
return (
@ -39,7 +39,6 @@ class TableHeader extends React.Component {
>
<span>
{header.label}
&nbsp;
{icon}
</span>

View File

@ -10,8 +10,20 @@
font-size: 1.3rem;
vertical-align: middle !important;
> span {
cursor: pointer;
}
}
}
.iconAsc{
margin-left: 5px;
&:before{
vertical-align: sub;
}
}
.iconDesc{
margin-left: 5px;
transform: translateY(-3px) rotateZ(180deg);
}

View File

@ -123,7 +123,7 @@ module.exports = {
if (association.nature === 'manyToMany' && !_.isArray(params.values[this.primaryKey])) {
value[details.via] = (value[details.via] || []).concat([params.values[this.primaryKey]]);
} else {
value[details.via] = params.values[this.primaryKey];
value[details.via] = params[this.primaryKey];
}
virtualFields.push(strapi.query(details.model || details.collection).addRelation({
@ -172,6 +172,7 @@ module.exports = {
},
delete: async function (params) {
// Delete entry.
return this
.remove({
[this.primaryKey]: params.id

View File

@ -84,9 +84,28 @@ module.exports = {
},
delete: async ctx => {
const params = ctx.params;
const response = await strapi.query(params.model).findOne({
id: params.id
})
params.values = Object.keys(JSON.parse(JSON.stringify(response))).reduce((acc, current) => {
const association = strapi.models[params.model].associations.filter(x => x.alias === current)[0];
// Remove relationships.
if (association) {
acc[current] = _.isArray(response[current]) ? [] : null;
}
return acc;
}, {});
// Run update to remove all relationships.
await strapi.query(params.model).update(params);
// Delete an entry using `queries` system
const entryDeleted = await strapi.query(ctx.params.model).delete({
id: ctx.params.id
const entryDeleted = await strapi.query(params.model).delete({
id: params.id
});
ctx.body = entryDeleted;