Comparing version 1.0.1 to 1.0.2
@@ -81,6 +81,6 @@ 'use strict'; | ||
function MLListItem$isDropAllowed(meta/*, dragDrop*/){ | ||
var component = componentsRegistry.get(meta.compClass); | ||
var Component = componentsRegistry.get(meta.compClass); | ||
return meta.params && meta.params.index | ||
&& (component == MLListItem || component.prototype instanceof MLListItem) | ||
&& (Component == MLListItem || Component.prototype instanceof MLListItem) | ||
&& draggingFromSameList.call(this); | ||
@@ -87,0 +87,0 @@ } |
@@ -6,2 +6,3 @@ 'use strict'; | ||
var SELECT_CHANGE_MESSAGE = 'mlselectchange'; | ||
@@ -12,4 +13,14 @@ var MLSelect = Component.createComponentClass('MLSelect', { | ||
}, | ||
data: undefined, | ||
events: undefined, | ||
data: { | ||
set: MLSelect_set, | ||
get: MLSelect_get, | ||
del: MLSelect_del, | ||
splice: undefined, | ||
event: SELECT_CHANGE_MESSAGE | ||
}, | ||
events: { | ||
messages: { | ||
'change': { subscriber: dispatchChangeMessage, context: 'owner' } | ||
} | ||
}, | ||
model: { | ||
@@ -34,2 +45,3 @@ messages: { | ||
_.extendProto(MLSelect, { | ||
init: MLSelect$init, | ||
setOptions: MLSelect$setOptions, | ||
@@ -40,2 +52,9 @@ disable: MLSelect$disable | ||
function MLSelect$init() { | ||
Component.prototype.init.apply(this, arguments); | ||
this._optionEls = {}; | ||
this._isMultiple = this.el.hasAttribute('multiple'); | ||
} | ||
function MLSelect$setOptions(options) { | ||
@@ -58,4 +77,48 @@ // Set options temporarily disables model subscriptions (As a workaround for performance issues relating to model updates / template re-rendering) | ||
function MLSelect_set(strOrObj) { | ||
if (!this._isMultiple) this.el.value = strOrObj; | ||
else { | ||
var valueObj = {}; | ||
if (strOrObj && typeof strOrObj == 'object') valueObj = strOrObj; | ||
else valueObj[strOrObj] = true; | ||
_.eachKey(this._optionEls, function (el, key) { | ||
el.selected = !!valueObj[key]; | ||
}); | ||
} | ||
} | ||
function MLSelect_get() { | ||
if (!this._isMultiple) return this.el.value; | ||
else { | ||
return _.mapKeys(this._optionEls, function (el) { | ||
return el.selected; | ||
}); | ||
} | ||
} | ||
function MLSelect_del() { | ||
if (!this._isMultiple) this.el.value = undefined; | ||
else { | ||
_.eachKey(this._optionEls, function (el) { | ||
el.selected = false; | ||
}); | ||
} | ||
} | ||
function dispatchChangeMessage() { | ||
this.data.dispatchSourceMessage(SELECT_CHANGE_MESSAGE); | ||
} | ||
function onOptionsChange(path, data) { | ||
this.template.render({ selectOptions: this.model.get() }); | ||
this._optionEls = {}; | ||
var self = this; | ||
_.forEach(this.el.querySelectorAll('option'), function (el) { | ||
self._optionEls[el.value] = el; | ||
}); | ||
//dispatchChangeMessage.call(this); | ||
} |
@@ -65,5 +65,6 @@ 'use strict'; | ||
miloCount: miloCount, | ||
disabled: item.disabled | ||
disabled: item.disabled, | ||
multiple: item.multiple | ||
}); | ||
} | ||
} |
@@ -34,2 +34,3 @@ 'use strict'; | ||
formRegistry.add('radio', { compClass: 'MLRadioGroup', itemFunction: processRadioSchema }); | ||
formRegistry.add('checkgroup', { compClass: 'MLCheckGroup', itemFunction: processCheckGroupSchema }); | ||
formRegistry.add('hyperlink', { compClass: 'MLHyperlink', template: hyperlink_dot, modelPathRule: 'optional' }); | ||
@@ -68,2 +69,9 @@ formRegistry.add('checkbox', { compClass: 'MLInput', template: checkbox_dot }); | ||
function processCheckGroupSchema(comp, schema) { | ||
var options = schema.checkOptions; | ||
comp.setSelectAll(!!schema.selectAll); | ||
setComponentOptions(comp, options, setComponentModel); | ||
} | ||
function processComboSchema(comp, schema) { | ||
@@ -70,0 +78,0 @@ var options = schema.comboOptions; |
@@ -11,2 +11,3 @@ 'use strict'; | ||
require('./components/RadioGroup'); | ||
require('./components/CheckGroup'); | ||
require('./components/Button'); | ||
@@ -13,0 +14,0 @@ require('./components/Hyperlink'); |
{ | ||
"name": "milo-ui", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "UI components and schema-based form generator for [milo.js](https://github.com/milojs/milo) framework", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
925967
71
9406