it("localizes the messages when other data bindings update", function (done) { message.key = "Hello, {name}"; var otherObject = { name: "before" }; var object = {}; Bindings.defineBinding(object, "name", { "<->": "name", source: otherObject, }); Bindings.defineBinding(message, "data.get('name')", { "<->": "name", source: object, }); message.localized.then(function (localized) { expect(localized).toBe("Hello, before"); otherObject.name = "after"; return message.localized; }).then(function (localized) { expect(localized).toBe("Hello, after"); }).catch(function (err) { fail(err); }).finally(function () { done(); }); });
it("localizes the messages when data bindings update", function () { message.key = "Hello, {name}"; var object = { name: "before" }; Bindings.defineBinding(message, "data.get('name')", { "<->": "name", source: object }); return message.localized.then(function (localized) { expect(localized).toBe("Hello, before"); object.name = "after"; return message.localized; }).then(function (localized) { expect(localized).toBe("Hello, after"); message.data.set("name", "later"); return message.localized; }).then(function (localized) { expect(localized).toBe("Hello, later"); expect(object.name).toBe("later"); }); });
value: function (event) { var detail = event.detail, columnContext = detail.columnContext, loadedComponent = detail.loadedComponent; if (columnContext.label === "Name" && !loadedComponent.getBinding("value")) { Bindings.defineBinding(loadedComponent, "value", {"<->": "object.id"}); } }
it("localizes the messages when message binding update", function () { var def = { key: "Hello, {name}" }; message.data = { name: "World" }; Bindings.defineBinding(message, "key", { "<->": "key", source: def }); return message.localized.then(function (localized) { expect(localized).toBe("Hello, World"); def.key = "Goodbye, {name}"; return message.localized; }).then(function (localized) { expect(localized).toBe("Goodbye, World"); }); });
value: function(isFirstTime) { if (isFirstTime) { Bindings.defineBinding(this, "linkState", {"<-": "status"}); Bindings.defineBinding(this, "isCardEnabled", {"<-": "enabledState"}); } }