Skip to content

Commit

Permalink
added setters
Browse files Browse the repository at this point in the history
  • Loading branch information
edsilv committed Oct 18, 2016
1 parent b2420af commit d0ccdaa
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2 deletions.
17 changes: 17 additions & 0 deletions dist/client/manifesto.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2184,18 +2184,35 @@ var Manifesto;
this.label = Manifesto.TranslationCollection.parse(this.resource.label, this.defaultLocale);
this.value = Manifesto.TranslationCollection.parse(this.resource.value, this.defaultLocale);
};
// shortcuts to get/set values based on default locale
MetadataItem.prototype.getLabel = function () {
if (this.label) {
return Manifesto.TranslationCollection.getValue(this.label, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setLabel = function (value) {
var _this = this;
if (this.label && this.label.length) {
var t = this.label.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
MetadataItem.prototype.getValue = function () {
if (this.value) {
return Manifesto.TranslationCollection.getValue(this.value, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setValue = function (value) {
var _this = this;
if (this.value && this.value.length) {
var t = this.value.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
return MetadataItem;
}());
Manifesto.MetadataItem = MetadataItem;
Expand Down
17 changes: 17 additions & 0 deletions dist/client/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2120,18 +2120,35 @@ var Manifesto;
this.label = Manifesto.TranslationCollection.parse(this.resource.label, this.defaultLocale);
this.value = Manifesto.TranslationCollection.parse(this.resource.value, this.defaultLocale);
};
// shortcuts to get/set values based on default locale
MetadataItem.prototype.getLabel = function () {
if (this.label) {
return Manifesto.TranslationCollection.getValue(this.label, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setLabel = function (value) {
var _this = this;
if (this.label && this.label.length) {
var t = this.label.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
MetadataItem.prototype.getValue = function () {
if (this.value) {
return Manifesto.TranslationCollection.getValue(this.value, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setValue = function (value) {
var _this = this;
if (this.value && this.value.length) {
var t = this.value.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
return MetadataItem;
}());
Manifesto.MetadataItem = MetadataItem;
Expand Down
2 changes: 1 addition & 1 deletion dist/client/manifesto.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/manifesto.bundle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,9 @@ declare module Manifesto {
constructor(defaultLocale: string);
parse(resource: any): void;
getLabel(): string;
setLabel(value: string): void;
getValue(): string;
setValue(value: string): void;
}
}

Expand Down
2 changes: 2 additions & 0 deletions dist/manifesto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,9 @@ declare module Manifesto {
constructor(defaultLocale: string);
parse(resource: any): void;
getLabel(): string;
setLabel(value: string): void;
getValue(): string;
setValue(value: string): void;
}
}

Expand Down
17 changes: 17 additions & 0 deletions dist/server/manifesto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,18 +2183,35 @@ var Manifesto;
this.label = Manifesto.TranslationCollection.parse(this.resource.label, this.defaultLocale);
this.value = Manifesto.TranslationCollection.parse(this.resource.value, this.defaultLocale);
};
// shortcuts to get/set values based on default locale
MetadataItem.prototype.getLabel = function () {
if (this.label) {
return Manifesto.TranslationCollection.getValue(this.label, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setLabel = function (value) {
var _this = this;
if (this.label && this.label.length) {
var t = this.label.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
MetadataItem.prototype.getValue = function () {
if (this.value) {
return Manifesto.TranslationCollection.getValue(this.value, this.defaultLocale);
}
return null;
};
MetadataItem.prototype.setValue = function (value) {
var _this = this;
if (this.value && this.value.length) {
var t = this.value.en().where(function (x) { return x.locale === _this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(_this.defaultLocale); }).first();
if (t)
t.value = value;
}
};
return MetadataItem;
}());
Manifesto.MetadataItem = MetadataItem;
Expand Down
2 changes: 1 addition & 1 deletion dist/server/manifesto.min.js

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions src/MetadataItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module Manifesto {
this.value = TranslationCollection.parse(this.resource.value, this.defaultLocale);
}

// shortcuts to get/set values based on default locale

public getLabel(): string {
if (this.label) {
return TranslationCollection.getValue(this.label, this.defaultLocale);
Expand All @@ -23,12 +25,26 @@ module Manifesto {
return null;
}

public setLabel(value: string): void {
if (this.label && this.label.length) {
var t: Manifesto.Translation = this.label.en().where(x => x.locale === this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(this.defaultLocale)).first();
if (t) t.value = value;
}
}

public getValue(): string {
if (this.value) {
return TranslationCollection.getValue(this.value, this.defaultLocale);
}

return null;
}

public setValue(value: string): void {
if (this.value && this.value.length) {
var t: Manifesto.Translation = this.value.en().where(x => x.locale === this.defaultLocale || x.locale === Manifesto.Utils.getInexactLocale(this.defaultLocale)).first();
if (t) t.value = value;
}
}
}
}

0 comments on commit d0ccdaa

Please sign in to comment.