cumulocity-hellowidget-plugin
Advanced tools
Comparing version 2.2.1 to 2.2.2
{ | ||
"name": "cumulocity-hellowidget-plugin", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "A demo app for showcasing creation of a custom Cumulocity UI widget plugin", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,6 +11,5 @@ /** | ||
.component('c8yHelloTextInput', { | ||
template: '<input ng-model="vm.helloText">', | ||
template: '<input ng-model="vm.config.helloText">', | ||
bindings: { | ||
device: '<', | ||
helloText: '=', | ||
config: '<', | ||
}, | ||
@@ -23,2 +22,3 @@ controllerAs: 'vm', | ||
const vm = this; | ||
const defaultConfig = { helloText: '' }; | ||
@@ -33,18 +33,18 @@ _.assign(vm, { | ||
function $onInit() { | ||
console.log(vm.helloText); | ||
_.defaults(vm.config, defaultConfig); | ||
vm.helloText = vm.helloText || ''; | ||
console.log(vm.config.helloText); | ||
} | ||
function $onChanges({ device }) { | ||
if (device) { | ||
onDeviceChange(); | ||
function $onChanges({ config }) { | ||
if (config) { | ||
onConfigChange(vm.config); | ||
} | ||
} | ||
function onDeviceChange() { | ||
const { device } = vm; | ||
function onConfigChange(config) { | ||
const deviceId = _.get(config, 'device.id'); | ||
if (device) { | ||
console.info('device id:', device.id); | ||
if (deviceId) { | ||
console.info('device id:', deviceId); | ||
} | ||
@@ -51,0 +51,0 @@ } |
@@ -55,3 +55,3 @@ /** | ||
const element = createComponent( | ||
'<c8y-hello-text-input hello-text="config.helloText" />', | ||
'<c8y-hello-text-input config="config" />', | ||
{ config: { helloText } }, | ||
@@ -58,0 +58,0 @@ ); |
@@ -13,3 +13,3 @@ /** | ||
bindings: { | ||
text: '<', | ||
config: '<', | ||
}, | ||
@@ -28,5 +28,5 @@ controllerAs: 'vm', | ||
function $onInit() { | ||
vm.text = vm.text || 'hello, world'; | ||
vm.text = _.get(vm, 'config.helloText', 'hello, world'); | ||
} | ||
} | ||
}()); |
@@ -51,3 +51,3 @@ /** | ||
// when | ||
const controller = $componentController('c8yHelloWidget', undefined, { text: textBinding }); | ||
const controller = $componentController('c8yHelloWidget', undefined, { config: { helloText: textBinding } }); | ||
controller.$onInit(); | ||
@@ -54,0 +54,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5424444
23