Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix action dropdown, update values based on context
- Loading branch information
Showing
with
42 additions
and
1 deletion.
-
+0
−1
ui/js/alerts.js
-
+42
−0
ui/js/exclude.js
|
|
@@ -56,7 +56,6 @@ jQuery( function( $ ) { |
|
|
var parts = value.split( '-' ); |
|
|
$( this ).siblings( '.connector' ).val( parts[0] ); |
|
|
$( this ).siblings( '.context' ).val( parts[1] ); |
|
|
// $(this).removeAttr('name'); |
|
|
} |
|
|
}); |
|
|
|
|
|
|
|
|
@@ -48,6 +48,14 @@ jQuery( function( $ ) { |
|
|
|
|
|
return null; |
|
|
} |
|
|
}).on( 'change', function() { |
|
|
var row = $( this ).closest( 'tr' ), |
|
|
connector = $( this ).val(); |
|
|
if ( connector && 0 < connector.indexOf( '-' ) ) { |
|
|
var connector_split = connector.split( '-' ); |
|
|
connector = connector_split[0]; |
|
|
} |
|
|
getActions( row, connector ); |
|
|
}); |
|
|
}); |
|
|
|
|
|
@@ -323,6 +331,40 @@ jQuery( function( $ ) { |
|
|
recalculate_rules_selected(); |
|
|
}); |
|
|
|
|
|
function getActions( row, connector ) { |
|
|
var trigger_action = $( '.select2-select.action', row ), |
|
|
action_value = trigger_action.val(); |
|
|
|
|
|
trigger_action.empty(); |
|
|
trigger_action.prop( 'disabled', true ); |
|
|
|
|
|
var placeholder = $( '<option/>', {value: '', text: ''} ); |
|
|
trigger_action.append( placeholder ); |
|
|
|
|
|
var data = { |
|
|
'action' : 'get_actions', |
|
|
'connector' : connector |
|
|
}; |
|
|
|
|
|
$.post( window.ajaxurl, data, function( response ) { |
|
|
var success = response.success, |
|
|
actions = response.data; |
|
|
if ( ! success ) { |
|
|
return; |
|
|
} |
|
|
for ( var key in actions ) { |
|
|
if ( actions.hasOwnProperty( key ) ) { |
|
|
var value = actions[key]; |
|
|
var option = $( '<option/>', {value: key, text: value} ); |
|
|
trigger_action.append( option ); |
|
|
} |
|
|
} |
|
|
trigger_action.val( action_value ); |
|
|
trigger_action.prop( 'disabled', false ); |
|
|
$( document ).trigger( 'alert-actions-updated' ); |
|
|
}); |
|
|
}; |
|
|
|
|
|
function recalculate_rules_selected() { |
|
|
var $selectedRows = $( 'table.stream-exclude-list tbody tr:not( .hidden ) input.cb-select:checked' ), |
|
|
$deleteButton = $( '#exclude_rules_remove_rules' ); |
|
|
|