Skip to content

Commit c48e6e6

Browse files
updated dynamic button title.
added selfclose for splitbutton fixed mf calls cleaned up console.logs
1 parent 7977c7d commit c48e6e6

File tree

4 files changed

+14
-49
lines changed

4 files changed

+14
-49
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Since the dropdown menu is based on bootstraps dropdown button it is recommended
3636
## Release Notes
3737
Appstore 1.5 release:
3838
- updated closing behaviour to be compatible with other similar custom widget closing constructions
39+
- added closing behaviour to split button click
3940
- updated to enable Mx 6.10+ compatibility
4041
- updated to support nesting a dropdown in a dropdown (note: set the outer one to non self-closing)
4142
- updated the testproject to higher version. Note that this release will therefore not be tested on 5.14.1 anymore.

src/DropdownDivConverter/widget/DropdownDivConverter.js

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ define([
4242
splitButtonActive: "",
4343
splitButtonClicked:"",
4444

45-
// Internal variables. Non-primitives created in the prototype are shared between all widget instances.
46-
_handles: null,
4745
_contextObj: null,
4846
_alertDiv: null,
4947
_allDropDowns: {},
@@ -54,7 +52,6 @@ define([
5452

5553
// dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
5654
constructor: function () {
57-
this._handles = [];
5855
this._eventsSet = false;
5956
},
6057

@@ -70,7 +67,7 @@ define([
7067

7168
// preset the label
7269
this._buttonLabel = this.buttonTitle;
73-
if (this.dynamicButtonTitle !== "" && this._contextObj !== null) {
70+
if (this.dynamicButtonTitleAttribute !== "" && this._contextObj !== null) {
7471
this._dynamicLabel = true;
7572
this._buttonLabel = this._contextObj.get(this.dynamicButtonTitleAttribute);
7673
}
@@ -95,7 +92,7 @@ define([
9592
_renderInterface: function(renderAsOpen, callback) {
9693
this.dropdownButton.innerHTML = this._buttonLabel + "<span class='caret'></span>";
9794
// if a glyphicon icon was requested and the splitButton is not wanted: add the glyphicon to the button.
98-
if (this.buttonGlyphicon !== '' && !this.splitButtonActive){
95+
if (this.buttonGlyphicon !== "" && !this.splitButtonActive){
9996
this._addGlyphicon(this.dropdownButton);
10097
}
10198

@@ -136,7 +133,6 @@ define([
136133
if(domClass.contains(this.domNode,"open")){
137134
domClass.remove(this.domNode,"open");
138135
this._isOpen = false;
139-
console.log("closing menu by document click;");
140136
}
141137
}
142138
}));
@@ -158,7 +154,6 @@ define([
158154
// Mendix buttons and links stop events from bubbling: set actions for internal button clicks to close the menu if needed
159155
if (this.autoClose){
160156
this.connect(this.dropdownMenu, 'click', lang.hitch(this,function(e){
161-
console.log("running close method via dropdown menu");
162157
if (this._isOpen) {
163158
this._toggleMenu();
164159
}
@@ -167,7 +162,6 @@ define([
167162
var internalButtons = domQuery("button, a", this.dropdownMenu);
168163
dojoArray.forEach(internalButtons, lang.hitch(this,function(node, i){
169164
this.connect(node, "click", lang.hitch(this, function(e) {
170-
console.log("triggering close method via internal button or a");
171165
if (this._isOpen){
172166
this._toggleMenu();
173167
}
@@ -177,7 +171,6 @@ define([
177171
var internalListviews = domQuery(".mx-listview-clickable .mx-list", this.dropdownMenu);
178172
dojoArray.forEach(internalListviews, lang.hitch(this,function(listNode, i){
179173
var listItemClick = lang.hitch(this,function(e) {
180-
console.log("triggering close method via listitem click");
181174
if (this._isOpen){
182175
this._toggleMenu();
183176
}});
@@ -192,7 +185,13 @@ define([
192185
// set the action for the possible split group button
193186
if (this.splitButtonActive){
194187
this.connect(this.splitButton, "click", lang.hitch(this, function(e){
195-
188+
// if the widget is set to autoclose: close the dropdown menu
189+
if (this.autoClose) {
190+
if (this._isOpen) {
191+
this._toggleMenu();
192+
}
193+
}
194+
196195
// if a microflow is checked and a contextobject is defined
197196
if (this.splitButtonClicked !== "" && this._contextObj) {
198197
// do we have a contextObj for the microflow?
@@ -277,23 +276,17 @@ define([
277276

278277
// Create a split button group
279278
_createSplitButton: function() {
280-
// create the new split button
281-
console.log("creating split button :" + this._buttonLabel);
279+
// create the new split button label
282280
this.splitButton.innerHTML = this._buttonLabel;
283281
// if a glyphicon icon was requested: add the glyphicon to the button.
284-
if (this.buttonGlyphicon !== ''){
282+
if (this.buttonGlyphicon !== ""){
285283
this._addGlyphicon(this.splitButton);
286284
}
287285
this._setButtonTypes(this.splitButton);
288286

289287
// adjust the dropdownButtons content
290288
this.dropdownButton.innerHTML = "<span class='caret'></span><span class='sr-only'>Toggle Dropdown</span";
291289
},
292-
293-
// set the label of the button
294-
_setButtonLabel: function(){
295-
296-
},
297290

298291
// Add a glyphicon to a button
299292
_addGlyphicon: function(buttonObject) {
@@ -302,44 +295,15 @@ define([
302295

303296
// Reset subscriptions.
304297
_resetSubscriptions: function () {
305-
var _objectHandle = null,
306-
_attrHandle = null,
307-
_validationHandle = null;
308-
309-
// Release handles on previous object, if any.
310-
if (this._handles) {
311-
dojoArray.forEach(this._handles, function(handle, i){
312-
mx.data.unsubscribe(handle);
313-
});
314-
315-
this._handles = [];
316-
}
317-
318-
// When a mendix object exists create subscribtions.
298+
this.unsubscribeAll();
319299
if (this._contextObj) {
320300

321-
_objectHandle = this.subscribe({
301+
this.subscribe({
322302
guid: this._contextObj.getGuid(),
323303
callback: lang.hitch(this, function (guid) {
324304
this._updateRendering();
325305
})
326306
});
327-
328-
_attrHandle = this.subscribe({
329-
guid: this._contextObj.getGuid(),
330-
attr: this.backgroundColor,
331-
callback: lang.hitch(this, function (guid, attr, attrValue) {
332-
this._updateRendering();
333-
})
334-
});
335-
336-
_validationHandle = this.subscribe({
337-
guid: this._contextObj.getGuid(),
338-
val: true,
339-
callback: lang.hitch(this, this._handleValidation)
340-
});
341-
342-
this._handles = [_objectHandle, _attrHandle, _validationHandle];
343307
}
344308
}
345309
});

test/Test.mpr

125 KB
Binary file not shown.
-319 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)