Skip to content

Commit

Permalink
feat: PS-261 - Support multiple selection for Channel organization in…
Browse files Browse the repository at this point in the history
…put (#226)

* feat: PS-261 - Support multiple selection for Channel organization input.

* Fix: PS-261 - Lint error

Co-authored-by: beyrul <beyrul.ibryam@softwaregroup-bg.com>
  • Loading branch information
beyrul and beyrul committed Mar 4, 2022
1 parent a16791b commit e300e67
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
3 changes: 2 additions & 1 deletion api/sql/schema/750-rule.rule.fetch.sql
Expand Up @@ -60,13 +60,14 @@ BEGIN

SELECT 'conditionActor' AS resultSetName
SELECT
ca.*, a.actorType AS [type]
ca.*, a.actorType AS [type], co.organizationName
FROM
[rule].conditionActor ca
JOIN
#RuleConditions rct ON rct.conditionId = ca.conditionId
JOIN
core.actor a ON a.actorId = ca.actorId
LEFT JOIN [customer].[organization] co ON co.actorId = ca.actorId

SELECT 'conditionItem' AS resultSetName
SELECT
Expand Down
14 changes: 11 additions & 3 deletions common/index.js
Expand Up @@ -47,7 +47,8 @@ function prepareRuleModel(dbresult) {
properties: [],
countries: [],
cities: [],
regions: []
regions: [],
organization: []
},
destination: {
properties: [],
Expand All @@ -74,8 +75,15 @@ function prepareRuleModel(dbresult) {
}
};
(dbresult.conditionActor || []).forEach((ca) => {
const des = rule[propMap[ca.factor]];
des && (des[ca.type] = parseInt(ca.actorId));
if (['organization'].indexOf(ca.type) > -1) {
const des = rule[propMap[ca.factor]];
des && des[ca.type] && des[ca.type].push({
key: parseInt(ca.actorId),
name: ca.organizationName
});
} else {
rule[propMap[ca.factor]] && (rule[propMap[ca.factor]][ca.type] = parseInt(ca.actorId));
}
});
// condition item
(dbresult.conditionItem || []).forEach((item) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"ut-port-script": "^7.2.0",
"ut-portal": "^7.10.0",
"ut-run": "^10.64.7",
"ut-tools": "^6.39.0"
"ut-tools": "^6.40.2"
},
"peerDependencies": {
"classnames": "^2.2.6",
Expand Down
3 changes: 1 addition & 2 deletions ui/react/pages/RuleProfile/Tabs/Channel/index.js
Expand Up @@ -5,7 +5,6 @@ import { bindActionCreators } from 'redux';
import { fromJS } from 'immutable';
import MultiSelectDropdown from 'ut-front-react/components/Input/MultiSelectDropdown';
import TitledContentBox from 'ut-front-react/components/TitledContentBox';
import Dropdown from 'ut-front-react/components/Input/Dropdown';
import Input from 'ut-front-react/components/Input';
import Property from '../../../../components/Property';
import style from '../style.css';
Expand Down Expand Up @@ -120,7 +119,7 @@ class ChannelTab extends Component {
/>
</div>}
{fields.organization.visible && <div className={style.inputWrapper}>
<Dropdown
<MultiSelectDropdown
disabled={readonly}
canSelectPlaceholder
keyProp='organization'
Expand Down
2 changes: 1 addition & 1 deletion ui/react/pages/RuleProfile/Tabs/defaultState.js
Expand Up @@ -66,7 +66,7 @@ export const defaultTabState = {
countries: [],
regions: [],
cities: [],
organization: '',
organization: [],
role: null,
properties: []
},
Expand Down
24 changes: 17 additions & 7 deletions ui/react/pages/RuleProfile/helpers.js
Expand Up @@ -79,13 +79,23 @@ export const prepareRuleToSave = (rule) => {
['channel', 'source', 'destination'].forEach(function(keyProp) {
const value = rule[keyProp];
['organization', 'role'].forEach((type) => {
value[type] && formattedRule.conditionActor.push(
{
actorId: value[type],
conditionId,
factor: conditionActorFactor[keyProp]
}
);
if (value[type] && value[type] instanceof Array) {
value[type].forEach(function(ci) {
ci.key && formattedRule.conditionActor.push({
actorId: ci.key,
conditionId,
factor: conditionActorFactor[keyProp]
});
});
} else {
value[type] && formattedRule.conditionActor.push(
{
actorId: value[type],
conditionId,
factor: conditionActorFactor[keyProp]
}
);
}
});
});

Expand Down
2 changes: 1 addition & 1 deletion ui/react/pages/Rules/reducer.js
Expand Up @@ -174,7 +174,7 @@ const getFormattedGridDataColumns = function(fetchedData, formattedRules) {

result[actor.conditionId][actor.factor].push({
name: actor.type,
value: actor.actorId
value: actor.type === 'organization' ? actor.organizationName : actor.actorId
});
});
Object.keys(formattedRules).forEach((conditionId) => {
Expand Down

0 comments on commit e300e67

Please sign in to comment.