Skip to content

Commit

Permalink
LPS-87975 Fixes issue where user can't delete a rule when there's onl…
Browse files Browse the repository at this point in the history
…y on rule to delete
  • Loading branch information
Bruno Basto committed Jan 23, 2019
1 parent 64a724f commit 9f0538b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Expand Up @@ -507,11 +507,9 @@ class LayoutProvider extends Component {
_handleRuleDeleted({ruleId}) {
const {rules} = this.state;

rules.splice(ruleId, 1);

this.setState(
{
rules
rules: rules.filter((rule, index) => index !== ruleId)
}
);
}
Expand Down
Expand Up @@ -214,7 +214,7 @@ class RuleBuilder extends Component {
}

willReceiveProps({rules}) {
if (rules && rules.newVal.length) {
if (rules && rules.newVal) {
this.setState(
{
rules: rules.newVal
Expand Down
Expand Up @@ -164,7 +164,7 @@ class RuleList extends Component {
const {roles} = this;
const rules = this._setDataProviderNames(states);

const newState = {
return {
...states,
rules: this._formatRules(
rules.map(
Expand Down Expand Up @@ -211,8 +211,6 @@ class RuleList extends Component {
),
rulesCardOptions: this._getRulesCardOptions()
};

return newState;
}

_formatActions(actions) {
Expand Down Expand Up @@ -369,7 +367,8 @@ class RuleList extends Component {
}

_handleRuleCardClicked({data, target}) {
const cardId = target.element.closest('[data-card-id]').getAttribute('data-card-id');
const cardElement = target.element.closest('[data-card-id]');
const cardId = parseInt(cardElement.getAttribute('data-card-id'), 10);

if (data.item.settingsItem == 'edit') {
this.emit(
Expand All @@ -390,11 +389,11 @@ class RuleList extends Component {
}

_setDataProviderNames(states) {
const newRules = states.rules;
const {rules} = states;

if (this.dataProvider) {
for (let rule = 0; rule < newRules.length; rule++) {
const actions = newRules[rule].actions;
for (let rule = 0; rule < rules.length; rule++) {
const actions = rules[rule].actions;

actions.forEach(
action => {
Expand All @@ -408,7 +407,7 @@ class RuleList extends Component {
}
}

return newRules;
return rules;
}

_setOperandValue(operand) {
Expand Down

0 comments on commit 9f0538b

Please sign in to comment.