@@ -454,7 +514,6 @@ export default class Devices extends ConsentComponent {
@@ -464,7 +523,6 @@ export default class Devices extends ConsentComponent {
@@ -472,7 +530,6 @@ export default class Devices extends ConsentComponent {
@@ -482,7 +539,6 @@ export default class Devices extends ConsentComponent {
@@ -490,7 +546,6 @@ export default class Devices extends ConsentComponent {
@@ -500,14 +555,31 @@ export default class Devices extends ConsentComponent {
{errorMessage}
-
-
- Add Device
-
+
+
+
+ {
+ isEdit ? (Edit Device)
+ : (Add Device)
+ }
+
+
+ {
+ isEdit && (
+
+ )
+ }
{
@@ -517,6 +589,7 @@ export default class Devices extends ConsentComponent {
deviceList={{ items: deviceItems }}
onDeleteItem={this.onHandleDeleteDevice}
disabled={!canModifyTrait}
+ onEditItem={this.onEditDevice}
/>
)
}
diff --git a/src/shared/components/Settings/Tools/Devices/styles.scss b/src/shared/components/Settings/Tools/Devices/styles.scss
index 3c14591819..0995ffc18c 100644
--- a/src/shared/components/Settings/Tools/Devices/styles.scss
+++ b/src/shared/components/Settings/Tools/Devices/styles.scss
@@ -155,7 +155,8 @@
}
}
- &.col-1 {
+ &.col-1,
+ &.col-1-no-padding {
width: 35%;
@include upto-sm {
@@ -200,32 +201,43 @@
}
}
-.button-save {
- align-self: center;
+.button-container {
+ display: flex;
+ justify-content: center;
+ align-items: center;
- @include upto-sm {
- margin-top: 10px;
- }
+ .button-save,
+ .button-cancel {
+ align-self: center;
- button,
- a {
- @include roboto-medium;
+ @include upto-sm {
+ margin-top: 10px;
+ }
- height: 40px;
- font-size: 15px;
- font-weight: 500;
- line-height: 40px;
- margin: 0;
- padding: 0;
- width: 199px;
+ button,
+ a {
+ @include roboto-medium;
- @include upto-sm {
- width: 156px;
+ height: 40px;
+ font-size: 15px;
+ font-weight: 500;
+ line-height: 40px;
+ margin: 0;
+ padding: 0;
+ width: 199px;
+
+ @include upto-sm {
+ width: 156px;
+ }
+ }
+
+ .complete {
+ color: $tc-white;
}
}
- .complete {
- color: $tc-white;
+ .button-cancel {
+ margin-left: 10px;
}
}
diff --git a/src/shared/components/Settings/Tools/ServiceProviders/List/Item/index.jsx b/src/shared/components/Settings/Tools/ServiceProviders/List/Item/index.jsx
index 63c00e3bd6..7c54d385d9 100644
--- a/src/shared/components/Settings/Tools/ServiceProviders/List/Item/index.jsx
+++ b/src/shared/components/Settings/Tools/ServiceProviders/List/Item/index.jsx
@@ -18,6 +18,7 @@ export default function Item(props) {
serviceProvider,
index,
onDeleteItem,
+ onEditItem,
} = props;
return (
@@ -35,18 +36,32 @@ export default function Item(props) {
-
onDeleteItem(index)}
- tabIndex={0}
- role="button"
- onClick={() => onDeleteItem(index)}
- >
-
-
-Delete
-
-
+
);
}
@@ -55,4 +70,5 @@ Item.propTypes = {
serviceProvider: PT.shape().isRequired,
index: PT.number.isRequired,
onDeleteItem: PT.func.isRequired,
+ onEditItem: PT.func.isRequired,
};
diff --git a/src/shared/components/Settings/Tools/ServiceProviders/List/Item/styles.scss b/src/shared/components/Settings/Tools/ServiceProviders/List/Item/styles.scss
index 5fe310a902..139340d53e 100644
--- a/src/shared/components/Settings/Tools/ServiceProviders/List/Item/styles.scss
+++ b/src/shared/components/Settings/Tools/ServiceProviders/List/Item/styles.scss
@@ -48,32 +48,69 @@
font-weight: 400;
}
-.delete {
+.operation-container {
display: flex;
- flex-direction: column;
- justify-items: center;
- justify-content: center;
- cursor: pointer;
- outline-style: none;
+ flex-direction: row;
+ justify-content: space-between;
- img {
- margin-bottom: 10px;
+ .delete {
+ display: flex;
+ flex-direction: column;
+ justify-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+ margin-left: 10px;
- @include upto-sm {
- margin-bottom: 0;
+ img {
+ margin-bottom: 10px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
+
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
+
+ @include upto-sm {
+ display: none;
+ }
}
}
- p {
- @include roboto-regular;
+ .edit {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+
+ img {
+ margin-bottom: 10px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
- font-size: 11px;
- line-height: 15px;
- font-weight: 400;
- color: $tc-gray-50;
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
- @include upto-sm {
- display: none;
+ @include upto-sm {
+ display: none;
+ }
}
}
}
diff --git a/src/shared/components/Settings/Tools/ServiceProviders/List/index.jsx b/src/shared/components/Settings/Tools/ServiceProviders/List/index.jsx
index 37acab7fdf..a04c0e69f6 100644
--- a/src/shared/components/Settings/Tools/ServiceProviders/List/index.jsx
+++ b/src/shared/components/Settings/Tools/ServiceProviders/List/index.jsx
@@ -12,6 +12,7 @@ export default function ServiceProviderList(props) {
serviceProviderList,
onDeleteItem,
disabled,
+ onEditItem,
} = props;
return (
@@ -20,7 +21,12 @@ export default function ServiceProviderList(props) {
{
serviceProviderList.items.map((serviceProvider, index) => (
-
+
))
}
@@ -32,6 +38,7 @@ export default function ServiceProviderList(props) {
ServiceProviderList.propTypes = {
serviceProviderList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
+ onEditItem: PT.func.isRequired,
disabled: PT.bool,
};
diff --git a/src/shared/components/Settings/Tools/ServiceProviders/index.jsx b/src/shared/components/Settings/Tools/ServiceProviders/index.jsx
index 16d4dd2674..4ece1d7f69 100644
--- a/src/shared/components/Settings/Tools/ServiceProviders/index.jsx
+++ b/src/shared/components/Settings/Tools/ServiceProviders/index.jsx
@@ -23,6 +23,7 @@ export default class ServiceProviders extends ConsentComponent {
super(props);
this.onHandleDeleteServiceProvider = this.onHandleDeleteServiceProvider.bind(this);
this.onDeleteServiceProvider = this.onDeleteServiceProvider.bind(this);
+ this.onEditServiceProvider = this.onEditServiceProvider.bind(this);
this.onUpdateSelect = this.onUpdateSelect.bind(this);
this.loadServiceProviderTrait = this.loadServiceProviderTrait.bind(this);
this.onUpdateInput = this.onUpdateInput.bind(this);
@@ -31,6 +32,8 @@ export default class ServiceProviders extends ConsentComponent {
this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this);
this.updatePredicate = this.updatePredicate.bind(this);
this.isFormValid = this.isFormValid.bind(this);
+ this.onCancelEditStatus = this.onCancelEditStatus.bind(this);
+
const { userTraits } = props;
this.state = {
formInvalid: false,
@@ -45,6 +48,7 @@ export default class ServiceProviders extends ConsentComponent {
screenSM: 767,
showConfirmation: false,
indexNo: null,
+ isEdit: false,
};
}
@@ -85,6 +89,22 @@ export default class ServiceProviders extends ConsentComponent {
this.showConsent(this.onAddServiceProvider.bind(this));
}
+ /**
+ * Edit Service Provider by index
+ * @param indexNo the Service Provider index no
+ */
+ onEditServiceProvider(indexNo) {
+ const { serviceProviderTrait } = this.state;
+ this.setState({
+ newServiceProvider: {
+ serviceProviderType: serviceProviderTrait.traits.data[indexNo].serviceProviderType,
+ name: serviceProviderTrait.traits.data[indexNo].name,
+ },
+ isEdit: true,
+ indexNo,
+ });
+ }
+
/**
* Check form fields value,
* Invalid value, can not save
@@ -156,7 +176,9 @@ export default class ServiceProviders extends ConsentComponent {
* @param answer user consent answer value
*/
onAddServiceProvider(answer) {
- const { newServiceProvider, personalizationTrait } = this.state;
+ const {
+ newServiceProvider, personalizationTrait, isEdit, indexNo,
+ } = this.state;
const {
handle,
@@ -167,6 +189,9 @@ export default class ServiceProviders extends ConsentComponent {
const { serviceProviderTrait } = this.state;
if (serviceProviderTrait.traits && serviceProviderTrait.traits.data.length > 0) {
const newServiceProviderTrait = { ...serviceProviderTrait };
+ if (isEdit) {
+ newServiceProviderTrait.traits.data.splice(indexNo, 1);
+ }
newServiceProviderTrait.traits.data.push(newServiceProvider);
this.setState({ serviceProviderTrait: newServiceProviderTrait });
updateUserTrait(handle, 'service_provider', newServiceProviderTrait.traits.data, tokenV3);
@@ -183,7 +208,11 @@ export default class ServiceProviders extends ConsentComponent {
serviceProviderType: '',
name: '',
};
- this.setState({ newServiceProvider: empty });
+ this.setState({
+ newServiceProvider: empty,
+ isEdit: false,
+ indexNo: null,
+ });
// save personalization
if (_.isEmpty(personalizationTrait)) {
const personalizationData = { userConsent: answer };
@@ -197,7 +226,6 @@ export default class ServiceProviders extends ConsentComponent {
}
}
-
/**
* Update input value
* @param e event
@@ -255,9 +283,23 @@ export default class ServiceProviders extends ConsentComponent {
return false;
}
+ onCancelEditStatus() {
+ const { isEdit } = this.state;
+ if (isEdit) {
+ this.setState({
+ isEdit: false,
+ indexNo: null,
+ newServiceProvider: {
+ serviceProviderType: '',
+ name: '',
+ },
+ });
+ }
+ }
+
render() {
const {
- serviceProviderTrait, isMobileView, showConfirmation, indexNo,
+ serviceProviderTrait, isMobileView, showConfirmation, indexNo, isEdit,
} = this.state;
const serviceProviderItems = serviceProviderTrait.traits
? serviceProviderTrait.traits.data.slice() : [];
@@ -289,11 +331,15 @@ export default class ServiceProviders extends ConsentComponent {
serviceProviderList={{ items: serviceProviderItems }}
onDeleteItem={this.onHandleDeleteServiceProvider}
disabled={!canModifyTrait}
+ onEditItem={this.onEditServiceProvider}
/>
)
}
0 ? 'second' : 'first'}`}>
- Add a new service provider
+ {
+ isEdit ? (Edit service provider)
+ : (Add a new service provider)
+ }
-
onDeleteItem(index)}
- tabIndex={0}
- role="button"
- onClick={() => onDeleteItem(index)}
- >
-
-
-Delete
-
-
+
);
}
@@ -55,4 +70,5 @@ Item.propTypes = {
software: PT.shape().isRequired,
index: PT.number.isRequired,
onDeleteItem: PT.func.isRequired,
+ onEditItem: PT.func.isRequired,
};
diff --git a/src/shared/components/Settings/Tools/Software/List/Item/styles.scss b/src/shared/components/Settings/Tools/Software/List/Item/styles.scss
index 5b8fa3b077..7c4c3f740c 100644
--- a/src/shared/components/Settings/Tools/Software/List/Item/styles.scss
+++ b/src/shared/components/Settings/Tools/Software/List/Item/styles.scss
@@ -52,32 +52,69 @@
font-weight: 400;
}
-.delete {
+.operation-container {
display: flex;
- flex-direction: column;
- justify-items: center;
- justify-content: center;
- cursor: pointer;
- outline-style: none;
+ flex-direction: row;
+ justify-content: space-between;
- img {
- margin-bottom: 10px;
+ .delete {
+ display: flex;
+ flex-direction: column;
+ justify-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+ margin-left: 10px;
- @include upto-sm {
- margin-bottom: 0;
+ img {
+ margin-bottom: 10px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
+
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
+
+ @include upto-sm {
+ display: none;
+ }
}
}
- p {
- @include roboto-regular;
+ .edit {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+
+ img {
+ margin-bottom: 10px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
- font-size: 11px;
- line-height: 15px;
- font-weight: 400;
- color: $tc-gray-50;
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
- @include upto-sm {
- display: none;
+ @include upto-sm {
+ display: none;
+ }
}
}
}
diff --git a/src/shared/components/Settings/Tools/Software/List/index.jsx b/src/shared/components/Settings/Tools/Software/List/index.jsx
index fe0a520f46..921010b1ce 100644
--- a/src/shared/components/Settings/Tools/Software/List/index.jsx
+++ b/src/shared/components/Settings/Tools/Software/List/index.jsx
@@ -12,6 +12,7 @@ export default function SoftwareList(props) {
softwareList,
onDeleteItem,
disabled,
+ onEditItem,
} = props;
return (
@@ -20,7 +21,12 @@ export default function SoftwareList(props) {
{
softwareList.items.map((software, index) => (
-
+
))
}
@@ -32,6 +38,7 @@ export default function SoftwareList(props) {
SoftwareList.propTypes = {
softwareList: PT.shape().isRequired,
onDeleteItem: PT.func.isRequired,
+ onEditItem: PT.func.isRequired,
disabled: PT.bool,
};
diff --git a/src/shared/components/Settings/Tools/Software/index.jsx b/src/shared/components/Settings/Tools/Software/index.jsx
index fd55f2279e..507b08b7d5 100644
--- a/src/shared/components/Settings/Tools/Software/index.jsx
+++ b/src/shared/components/Settings/Tools/Software/index.jsx
@@ -24,6 +24,7 @@ export default class Software extends ConsentComponent {
super(props);
this.onHandleDeleteSoftware = this.onHandleDeleteSoftware.bind(this);
this.onDeleteSoftware = this.onDeleteSoftware.bind(this);
+ this.onEditSoftware = this.onEditSoftware.bind(this);
this.onUpdateSelect = this.onUpdateSelect.bind(this);
this.loadSoftwareTrait = this.loadSoftwareTrait.bind(this);
this.onUpdateInput = this.onUpdateInput.bind(this);
@@ -31,6 +32,7 @@ export default class Software extends ConsentComponent {
this.onAddSoftware = this.onAddSoftware.bind(this);
this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this);
this.updatePredicate = this.updatePredicate.bind(this);
+ this.onCancelEditStatus = this.onCancelEditStatus.bind(this);
const { userTraits } = props;
this.state = {
@@ -46,6 +48,7 @@ export default class Software extends ConsentComponent {
screenSM: 767,
showConfirmation: false,
indexNo: null,
+ isEdit: false,
};
}
@@ -152,12 +155,30 @@ export default class Software extends ConsentComponent {
});
}
+ /**
+ * Edit software by index
+ * @param indexNo the software index no
+ */
+ onEditSoftware(indexNo) {
+ const { softwareTrait } = this.state;
+ this.setState({
+ newSoftware: {
+ softwareType: softwareTrait.traits.data[indexNo].softwareType,
+ name: softwareTrait.traits.data[indexNo].name,
+ },
+ isEdit: true,
+ indexNo,
+ });
+ }
+
/**
* Add new software
* @param answer user consent answer value
*/
onAddSoftware(answer) {
- const { newSoftware, personalizationTrait } = this.state;
+ const {
+ newSoftware, personalizationTrait, isEdit, indexNo,
+ } = this.state;
const {
handle,
@@ -168,6 +189,9 @@ export default class Software extends ConsentComponent {
const { softwareTrait } = this.state;
if (softwareTrait.traits && softwareTrait.traits.data.length > 0) {
const newSoftwareTrait = { ...softwareTrait };
+ if (isEdit) {
+ newSoftwareTrait.traits.data.splice(indexNo, 1);
+ }
newSoftwareTrait.traits.data.push(newSoftware);
this.setState({ softwareTrait: newSoftwareTrait });
updateUserTrait(handle, 'software', newSoftwareTrait.traits.data, tokenV3);
@@ -184,7 +208,11 @@ export default class Software extends ConsentComponent {
softwareType: '',
name: '',
};
- this.setState({ newSoftware: empty });
+ this.setState({
+ newSoftware: empty,
+ isEdit: false,
+ indexNo: null,
+ });
// save personalization
if (_.isEmpty(personalizationTrait)) {
const personalizationData = { userConsent: answer };
@@ -255,9 +283,23 @@ export default class Software extends ConsentComponent {
return false;
}
+ onCancelEditStatus() {
+ const { isEdit } = this.state;
+ if (isEdit) {
+ this.setState({
+ isEdit: false,
+ indexNo: null,
+ newSoftware: {
+ softwareType: '',
+ name: '',
+ },
+ });
+ }
+ }
+
render() {
const {
- softwareTrait, isMobileView, showConfirmation, indexNo,
+ softwareTrait, isMobileView, showConfirmation, indexNo, isEdit,
} = this.state;
const softwareItems = softwareTrait.traits
? softwareTrait.traits.data.slice() : [];
@@ -289,11 +331,15 @@ export default class Software extends ConsentComponent {
softwareList={{ items: softwareItems }}
onDeleteItem={this.onHandleDeleteSoftware}
disabled={!canModifyTrait}
+ onEditItem={this.onEditSoftware}
/>
)
}
0 ? 'second' : 'first'}`}>
- Add a new software
+ {
+ isEdit ? (Edit software)
+ : (Add a new software)
+ }
-
onDeleteItem(index)}
- tabIndex={0}
- role="button"
- onClick={() => onDeleteItem(index)}
- >
-
-
-Delete
-
-
+
);
}
@@ -52,4 +67,5 @@ Item.propTypes = {
subscription: PT.shape().isRequired,
index: PT.number.isRequired,
onDeleteItem: PT.func.isRequired,
+ onEditItem: PT.func.isRequired,
};
diff --git a/src/shared/components/Settings/Tools/Subscriptions/List/Item/styles.scss b/src/shared/components/Settings/Tools/Subscriptions/List/Item/styles.scss
index db86dc5800..58d84f0fbd 100644
--- a/src/shared/components/Settings/Tools/Subscriptions/List/Item/styles.scss
+++ b/src/shared/components/Settings/Tools/Subscriptions/List/Item/styles.scss
@@ -47,33 +47,72 @@
word-break: break-all;
}
-.delete {
+.operation-container {
display: flex;
- flex-direction: column;
- align-items: center;
- justify-items: center;
- justify-content: center;
- cursor: pointer;
- outline-style: none;
+ flex-direction: row;
+ justify-content: space-between;
- img {
- margin-bottom: 10px;
+ .delete {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+ margin-left: 10px;
- @include upto-sm {
- margin-bottom: 0;
+ img {
+ margin-bottom: 10px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
+
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
+
+ @include upto-sm {
+ display: none;
+ }
}
}
- p {
- @include roboto-regular;
+ .edit {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ outline-style: none;
+
+ img {
+ margin-bottom: 10px;
+ width: 15px;
+ height: 15px;
+
+ @include upto-sm {
+ margin-bottom: 0;
+ }
+ }
+
+ p {
+ @include roboto-regular;
- font-size: 11px;
- line-height: 15px;
- font-weight: 400;
- color: $tc-gray-50;
+ font-size: 11px;
+ line-height: 15px;
+ font-weight: 400;
+ color: $tc-gray-50;
- @include upto-sm {
- display: none;
+ @include upto-sm {
+ display: none;
+ }
}
}
}
diff --git a/src/shared/components/Settings/Tools/Subscriptions/List/index.jsx b/src/shared/components/Settings/Tools/Subscriptions/List/index.jsx
index e63fe7acc8..2a9fd47cf1 100644
--- a/src/shared/components/Settings/Tools/Subscriptions/List/index.jsx
+++ b/src/shared/components/Settings/Tools/Subscriptions/List/index.jsx
@@ -12,6 +12,7 @@ export default function SubscriptionList(props) {
subscriptionList,
onDeleteItem,
disabled,
+ onEditItem,
} = props;
return (
@@ -20,7 +21,12 @@ export default function SubscriptionList(props) {
{
subscriptionList.items.map((subscription, index) => (
0 ? 'second' : 'first'}`}>
- Add a new subscription
+ {
+ isEdit ? (Edit subscription)
+ : (Add a new subscription)
+ }