Skip to content

Commit 5f4c68f

Browse files
committed
[DSC-714] Fix indentation and refactoring
1 parent 9ee4984 commit 5f4c68f

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

src/app/core/json-patch/builder/json-patch-operations-builder.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,25 @@ export class JsonPatchOperationsBuilder {
110110
operationValue = [];
111111
value.forEach((entry) => {
112112
if ((typeof entry === 'object')) {
113-
if (securityLevel != null) {
113+
if (isNotEmpty(securityLevel)) {
114114
operationValue.push(this.prepareObjectValue(entry, securityLevel));
115115
} else {
116116
operationValue.push(this.prepareObjectValue(entry));
117117
}
118-
119118
} else {
120119
operationValue.push(new FormFieldMetadataValueObject(entry, null, securityLevel));
121120
}
122121
});
123122
} else if (typeof value === 'object') {
124-
if (securityLevel != null) {
123+
if (isNotEmpty(securityLevel)) {
125124
operationValue = this.prepareObjectValue(value, securityLevel);
126125
} else {
127126
operationValue = this.prepareObjectValue(value);
128127
}
129-
130128
} else {
131129
// add the possibility to add security level when value is string
132130
// in this case security level is set on metadata value
133-
if (securityLevel != null) {
131+
if (isNotEmpty(securityLevel)) {
134132
operationValue = new FormFieldMetadataValueObject(value, null, securityLevel);
135133
} else {
136134
operationValue = new FormFieldMetadataValueObject(value, null);
@@ -143,16 +141,16 @@ export class JsonPatchOperationsBuilder {
143141
}
144142

145143
protected prepareObjectValue(value: any, securityLevel = null) {
146-
let operationValue = Object.create({});
144+
let operationValue = Object.create({});
147145
if (isEmpty(value) || value instanceof FormFieldMetadataValueObject) {
148-
if (securityLevel != null) {
149-
operationValue = {...value, securityLevel: securityLevel};
150-
} else {
146+
if (isNotEmpty(securityLevel)) {
147+
operationValue = { ...value, securityLevel: securityLevel };
148+
} else {
151149
operationValue = value;
152150
}
153151
} else if (value instanceof Date) {
154152
if (securityLevel != null) {
155-
operationValue = new FormFieldMetadataValueObject(dateToISOFormat(value), null, securityLevel);
153+
operationValue = new FormFieldMetadataValueObject(dateToISOFormat(value), null, securityLevel);
156154
} else {
157155
operationValue = new FormFieldMetadataValueObject(dateToISOFormat(value));
158156
}
@@ -170,11 +168,10 @@ export class JsonPatchOperationsBuilder {
170168
Object.keys(value)
171169
.forEach((key) => {
172170
if (typeof value[key] === 'object') {
173-
if (securityLevel != null) {
174-
operationValue[key] = this.prepareObjectValue(value[key], securityLevel);
171+
if (isNotEmpty(securityLevel)) {
172+
operationValue[key] = this.prepareObjectValue(value[key], securityLevel);
175173
} else {
176-
operationValue[key] = this.prepareObjectValue(value[key]);
177-
174+
operationValue[key] = this.prepareObjectValue(value[key]);
178175
}
179176
} else {
180177
operationValue[key] = value[key];

0 commit comments

Comments
 (0)