mirror of
https://github.com/strapi/strapi.git
synced 2025-12-28 23:57:32 +00:00
Improve design sorting arrow
This commit is contained in:
parent
e64e5414ce
commit
6b83375009
@ -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}
|
||||
|
||||
{icon}
|
||||
</span>
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user