Segments page review

- remove edit link for WordPress users list
- hide trashed segments from Import
- fixed display issue in listing's item actions
This commit is contained in:
Jonathan Labreuille
2016-02-12 11:30:08 +01:00
parent 214aa60d0e
commit e928a5c2bc
4 changed files with 26 additions and 13 deletions

View File

@ -74,10 +74,11 @@ define(
);
}
var custom_actions = this.props.item_actions;
var item_actions = false;
const custom_actions = this.props.item_actions;
let item_actions = false;
if(custom_actions.length > 0) {
let is_first = true;
item_actions = custom_actions.map(function(action, index) {
if(action.display !== undefined) {
if(action.display(this.props.item) === false) {
@ -85,10 +86,12 @@ define(
}
}
let custom_action = null;
if(action.name === 'trash') {
return (
custom_action = (
<span key={ 'action-'+index } className="trash">
{(index > 0) ? ' | ' : ''}
{(!is_first) ? ' | ' : ''}
<a
href="javascript:;"
onClick={ this.handleTrashItem.bind(
@ -100,27 +103,27 @@ define(
</span>
);
} else if(action.refresh) {
return (
custom_action = (
<span
onClick={ this.props.onRefreshItems }
key={ 'action-'+index } className={ action.name }>
{(index > 0) ? ' | ' : ''}
{(!is_first) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else if(action.link) {
return (
custom_action = (
<span
key={ 'action-'+index } className={ action.name }>
{(index > 0) ? ' | ' : ''}
{(!is_first) ? ' | ' : ''}
{ action.link(this.props.item) }
</span>
);
} else {
return (
custom_action = (
<span
key={ 'action-'+index } className={ action.name }>
{(index > 0) ? ' | ' : ''}
{(!is_first) ? ' | ' : ''}
<a href="javascript:;" onClick={
(action.onClick !== undefined)
? action.onClick.bind(null,
@ -132,6 +135,12 @@ define(
</span>
);
}
if(custom_action !== null && is_first === true) {
is_first = false;
}
return custom_action;
}.bind(this));
} else {
item_actions = (

View File

@ -12,7 +12,7 @@ define(
Form
) {
var fields = [
let fields = [
{
name: 'name',
label: 'Name',
@ -25,7 +25,7 @@ define(
}
];
var messages = {
const messages = {
onUpdate: function() {
MailPoet.Notice.success('Segment successfully updated!');
},
@ -34,7 +34,7 @@ define(
}
};
var SegmentForm = React.createClass({
const SegmentForm = React.createClass({
mixins: [
Router.History
],

View File

@ -96,6 +96,9 @@ const item_actions = [
return (
<Link to={ `/edit/${item.id}` }>Edit</Link>
);
},
display: function(segment) {
return (segment.type !== 'wp_users');
}
},
{

View File

@ -122,6 +122,7 @@ class Segment extends Model {
->group_by(self::$_table.'.id')
->group_by(self::$_table.'.name')
->where(self::$_table.'.type', 'default')
->whereNull(self::$_table.'.deleted_at')
->findArray();
}