Skip to content

Commit

Permalink
Check if value should be added or updated when setting default value …
Browse files Browse the repository at this point in the history
…to attribute #47
  • Loading branch information
PagnoDunadan committed Jan 24, 2019
1 parent dc6c2f4 commit 5210c80
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/shared/services/item.service.ts
Expand Up @@ -164,8 +164,15 @@ export class ItemService {
settingsTranslated: EavAttributesTranslated, currentLanguage: string, defaultLanguage: string): any {
const defaultValue = InputFieldHelper.parseDefaultValue(attribute.name, inputType, settingsTranslated, item.header);

this.updateItemAttributeValue(item.entity.id, attribute.name,
defaultValue, currentLanguage, defaultLanguage, false, item.entity.guid);
const exists = item.entity.attributes.hasOwnProperty(attribute.name);
if (!exists) {
this.addAttributeValue(item.entity.id, attribute.name,
defaultValue, currentLanguage, false, item.entity.guid, attribute.type);
} else {
this.updateItemAttributeValue(item.entity.id, attribute.name,
defaultValue, currentLanguage, defaultLanguage, false, item.entity.guid);
}

return defaultValue;
}

Expand Down

0 comments on commit 5210c80

Please sign in to comment.