Skip to content

Commit 52b63b0

Browse files
fixed a lot of new input.
Note - still working on attribute as a button label so in progress still
1 parent 0a1635b commit 52b63b0

File tree

11 files changed

+213
-32
lines changed

11 files changed

+213
-32
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@ test/javasource/
22
test/deployment/
33
test/.classpath
44
test/.project
5+
test/theme/
6+
test/userlib/
7+
test/.classpath
8+
test/.project
59
*.launch
610
*.tmp
711
*.lock
812
.idea/
13+
14+
dist/
15+
16+
node_modules/
17+
.editorconfig
18+
*DS_Store*
19+
.vscode/
20+
*.bak

.jshintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Enforcing
3+
"curly" : false,
4+
"forin" : false,
5+
"latedef" : "nofunc",
6+
"newcap" : true,
7+
"quotmark" : "double",
8+
"eqeqeq" : true,
9+
"undef" : true,
10+
"globals" : {
11+
"mendix" : false,
12+
"mx" : false,
13+
"logger" : false
14+
},
15+
16+
// Relaxing
17+
"laxbreak" : true,
18+
19+
// Environments
20+
"browser" : true,
21+
"devel" : true,
22+
"dojo" : true
23+
}

Gulpfile.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Generated on 2016-11-03 using generator-mendix 2.0.1 :: git+https://github.com/mendix/generator-mendix.git
2+
/*jshint -W069,-W097*/
3+
"use strict";
4+
5+
// In case you seem to have trouble starting Mendix through `gulp modeler`, you might have to set the path to the Mendix application, otherwise leave both values as they are
6+
var MODELER_PATH = null;
7+
var MODELER_ARGS = "/file:{path}";
8+
9+
/********************************************************************************
10+
* Do not edit anything below, unless you know what you are doing
11+
********************************************************************************/
12+
var gulp = require("gulp"),
13+
zip = require("gulp-zip"),
14+
del = require("del"),
15+
newer = require("gulp-newer"),
16+
gutil = require("gulp-util"),
17+
gulpif = require("gulp-if"),
18+
jsonTransform = require("gulp-json-transform"),
19+
intercept = require("gulp-intercept"),
20+
argv = require("yargs").argv,
21+
widgetBuilderHelper = require("widgetbuilder-gulp-helper");
22+
23+
var pkg = require("./package.json"),
24+
paths = widgetBuilderHelper.generatePaths(pkg),
25+
xmlversion = widgetBuilderHelper.xmlversion;
26+
27+
gulp.task("default", function() {
28+
gulp.watch("./src/**/*", ["compress"]);
29+
gulp.watch("./src/**/*.js", ["copy:js"]);
30+
});
31+
32+
gulp.task("clean", function () {
33+
return del([
34+
paths.WIDGET_TEST_DEST,
35+
paths.WIDGET_DIST_DEST
36+
], { force: true });
37+
});
38+
39+
gulp.task("compress", ["clean"], function () {
40+
return gulp.src("src/**/*")
41+
.pipe(zip(pkg.name + ".mpk"))
42+
.pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER))
43+
.pipe(gulp.dest("dist"));
44+
});
45+
46+
gulp.task("copy:js", function () {
47+
return gulp.src(["./src/**/*.js"])
48+
.pipe(newer(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER))
49+
.pipe(gulp.dest(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER));
50+
});
51+
52+
gulp.task("version:xml", function () {
53+
return gulp.src(paths.PACKAGE_XML)
54+
.pipe(xmlversion(argv.n))
55+
.pipe(gulp.dest("./src/"));
56+
});
57+
58+
gulp.task("version:json", function () {
59+
return gulp.src("./package.json")
60+
.pipe(gulpif(typeof argv.n !== "undefined", jsonTransform(function(data) {
61+
data.version = argv.n;
62+
return data;
63+
}, 2)))
64+
.pipe(gulp.dest("./"));
65+
});
66+
67+
gulp.task("icon", function (cb) {
68+
var icon = (typeof argv.file !== "undefined") ? argv.file : "./icon.png";
69+
console.log("\nUsing this file to create a base64 string: " + gutil.colors.cyan(icon));
70+
gulp.src(icon)
71+
.pipe(intercept(function (file) {
72+
console.log("\nCopy the following to your " + pkg.name + ".xml (after description):\n\n" + gutil.colors.cyan("<icon>") + file.contents.toString("base64") + gutil.colors.cyan("<\\icon>") + "\n");
73+
cb();
74+
}));
75+
});
76+
77+
gulp.task("folders", function () {
78+
paths.showPaths(); return;
79+
});
80+
81+
gulp.task("modeler", function (cb) {
82+
widgetBuilderHelper.runmodeler(MODELER_PATH, MODELER_ARGS, paths.TEST_PATH, cb);
83+
});
84+
85+
gulp.task("build", ["compress"]);
86+
gulp.task("version", ["version:xml", "version:json"]);

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ It's possible to use multiple DropdownDivConverter widgets on the same page. Tha
3434
Since the dropdown menu is based on bootstraps dropdown button it is recommended to follow the applications Bootstrap theming rules with respect to buttons.
3535

3636
## Release Notes
37+
Appstore 1.5 release:
38+
- updated closing behaviour to be compatible with other similar custom widget closing constructions
39+
- updated to enable Mx 6.10+ compatibility
40+
- updated to support nesting a dropdown in a dropdown (note: set the outer one to non self-closing)
41+
- updated the testproject to higher version. Note that this release will therefore not be tested on 5.14.1 anymore.
42+
3743
Appstore 1.4 release:
3844
- added self closing behaviour support for clickable listview (listviews with a microflow 'on click' property).
3945

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "DropdownDivConverter",
3+
"version": "1.5.0",
4+
"description": "The DropdownDivConverter converts a Mendix (div-)container into a - Bootstrap based - dropdown menu with a button. Simply create a container in Mendix with all the content you want in the dropdown menu and the DropdownDivConverter widget as it's last child. Everything you will have added then becomes the content of the dropdown menu.",
5+
"license": "Apache 2",
6+
"author": "Willem Gorisse",
7+
"private": true,
8+
"dependencies": {
9+
},
10+
"devDependencies": {
11+
"del": "^2.2.2",
12+
"gulp": "^3.9.1",
13+
"gulp-if": "^2.0.1",
14+
"gulp-intercept": "^0.1.0",
15+
"gulp-json-transform": "^0.4.2",
16+
"gulp-newer": "^1.3.0",
17+
"gulp-util": "^3.0.7",
18+
"gulp-zip": "^3.2.0",
19+
"widgetbuilder-gulp-helper": "https://github.com/JelteMX/widgetbuilder-gulp-helper/archive/1.0.1.tar.gz",
20+
"yargs": "^6.0.0"
21+
},
22+
"engines": {
23+
"node": ">=5"
24+
},
25+
"generatorVersion": "2.0.1",
26+
"paths": {
27+
"testProjectFolder": "./test/",
28+
"testProjectFileName": "Test.mpr"
29+
},
30+
"scripts": {
31+
"build": "node ./node_modules/gulp/bin/gulp build",
32+
"version": "node ./node_modules/gulp/bin/gulp version",
33+
"icon": "node ./node_modules/gulp/bin/gulp icon",
34+
"folders": "node ./node_modules/gulp/bin/gulp folders",
35+
"modeler": "node ./node_modules/gulp/bin/gulp modeler"
36+
}
37+
}

src/DropdownDivConverter/DropdownDivConverter.xml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<property key="buttonTitle" type="string" defaultValue="" required="false">
1010
<caption>Dropdown button label</caption>
1111
<category>General</category>
12-
<description>The label on the dropdown button.</description>
12+
<description>The label on the dropdown button. Note, can be overridden on the Data Source tab</description>
1313
</property>
1414
<property key="buttonGlyphicon" type="string" defaultValue="" required="false">
1515
<caption>Glyphicon icon</caption>
@@ -61,6 +61,19 @@
6161
<enumerationValue key="link">link</enumerationValue>
6262
</enumerationValues>
6363
</property>
64+
<property key="contextObject" type="entity" required="false" allowNonPersistableEntities="true">
65+
<caption>Context object</caption>
66+
<category>Data Source</category>
67+
<description>The entity required for the microflow or dynamic label</description>
68+
</property>
69+
<property key="dynamicButtonTitleAttribute" type="attribute" entityProperty="contextObject" required="false">
70+
<caption>Dynamic button label</caption>
71+
<category>Data Source</category>
72+
<description>The attribute that sets the label on the dropdown button. If used, the static value on the general tab will be overridden.</description>
73+
<attributeTypes>
74+
<attributeType name="String" />
75+
</attributeTypes>
76+
</property>
6477
<property key="splitButtonActive" type="boolean" defaultValue="false" required="true">
6578
<caption>Split button dropdown</caption>
6679
<category>Split button</category>
@@ -75,15 +88,9 @@
7588
<property key="splitButtonClicked" type="microflow" required="false" defaultValue="" entityProperty="contextObject">
7689
<caption>Microflow</caption>
7790
<category>Split button</category>
78-
<description>A entity driven microflow which is triggered if the main split button is clicked.</description>
91+
<description>A entity driven microflow which is triggered if the main split button is clicked. Note that the Context Object from the Data Source tab is required.</description>
7992
<returnType type="Object" entityProperty="contextObject" ></returnType>
8093
</property>
81-
<property key="contextObject" type="entity" required="false">
82-
<caption>Context object</caption>
83-
<category>Split button</category>
84-
<description>The entity required for the microflow.</description>
85-
</property>
86-
8794
</properties>
8895
</widget>
8996

src/DropdownDivConverter/widget/DropdownDivConverter.js

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ define([
3333

3434
// Parameters configured in the Modeler.
3535
buttonTitle: "",
36+
dynamicButtonTitleAttribute: "",
3637
buttonGlyphicon: "",
3738
isDropUp: "",
3839
isRightAligned: "",
@@ -48,6 +49,8 @@ define([
4849
_allDropDowns: {},
4950
_eventsSet: null,
5051
_isOpen: null,
52+
_buttonLabel: null,
53+
_dynamicLabel: false,
5154

5255
// dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
5356
constructor: function () {
@@ -68,6 +71,11 @@ define([
6871
this._resetSubscriptions();
6972
this._updateRendering(callback);
7073

74+
// preset the label
75+
this._buttonlabel = this.buttonTitle;
76+
if (this.dynamicButtonTitle != "") {
77+
this._dynamicLabel = true;
78+
}
7179
},
7280

7381
// Reordering the interface: selecting the siblings and putting them in the dropdown menu
@@ -106,6 +114,7 @@ define([
106114
}
107115
}
108116
if (this.splitButtonActive) {
117+
console.log("createing split button call: "+ this._buttonLabel)
109118
this._createSplitButton();
110119
} else {
111120
domConstruct.destroy(this.splitButton);
@@ -123,26 +132,19 @@ define([
123132
// set window click
124133
this.connect(document, "click", lang.hitch(this,function(event){
125134
// if a widget external click is made: close the menu if open
126-
if(domClass.contains(this.domNode,"open")){
127-
domClass.remove(this.domNode,"open");
128-
this._isOpen = false;
129-
}
135+
if (!this.domNode.contains(event.target)) {
136+
if(domClass.contains(this.domNode,"open")){
137+
domClass.remove(this.domNode,"open");
138+
this._isOpen = false;
139+
console.log("closing menu by document click;");
140+
}
141+
}
130142
}));
131143

132144
// set action for the normal dropdown button
133145
this.connect(this.dropdownButton, "click", lang.hitch(this,function(e){
134-
event.stop(e);
135-
var dropdown = null;
136-
137-
for(dropdown in this._allDropDowns) {
138-
if (this._allDropDowns.hasOwnProperty(dropdown) && dropdown !== this.id){
139-
if (this._allDropDowns[dropdown]._isOpen === true) {
140-
domClass.remove(this._allDropDowns[dropdown].domNode, "open");
141-
this._allDropDowns[dropdown]._isOpen = false;
142-
}
143-
}
144-
}
145-
146+
//event.stop(e);
147+
var dropdown = null;
146148
this._toggleMenu();
147149
}));
148150

@@ -155,9 +157,17 @@ define([
155157

156158
// Mendix buttons and links stop events from bubbling: set actions for internal button clicks to close the menu if needed
157159
if (this.autoClose){
160+
this.connect(this.dropdownMenu, 'click', lang.hitch(this,function(e){
161+
console.log("running close method via dropdown menu");
162+
if (this._isOpen) {
163+
this._toggleMenu();
164+
}
165+
}));
166+
158167
var internalButtons = domQuery("button, a", this.dropdownMenu);
159168
dojoArray.forEach(internalButtons, lang.hitch(this,function(node, i){
160169
this.connect(node, "click", lang.hitch(this, function(e) {
170+
console.log("triggering close method via internal button or a");
161171
if (this._isOpen){
162172
this._toggleMenu();
163173
}
@@ -167,6 +177,7 @@ define([
167177
var internalListviews = domQuery(".mx-listview-clickable .mx-list", this.dropdownMenu);
168178
dojoArray.forEach(internalListviews, lang.hitch(this,function(listNode, i){
169179
var listItemClick = lang.hitch(this,function(e) {
180+
console.log("triggering close method via listitem click");
170181
if (this._isOpen){
171182
this._toggleMenu();
172183
}});
@@ -188,10 +199,9 @@ define([
188199

189200
var id = this._contextObj.getGuid();
190201

191-
mx.data.action({
202+
mx.ui.action(this.splitButtonClicked, {
192203
params : {
193204
applyto : "selection",
194-
actionname : this.splitButtonClicked,
195205
guids : [id]
196206
},
197207
callback : function(success) {
@@ -203,10 +213,9 @@ define([
203213
}, this);
204214
} else if (this.simpleSplitButtonClicked !== "") {
205215

206-
mx.data.action({
216+
mx.ui.action(this.simpleSplitButtonClicked, {
207217
params : {
208-
applyto : "none",
209-
actionname : this.simpleSplitButtonClicked
218+
applyto : "none"
210219
},
211220
callback : function(success) {
212221
// if success was true, the microflow was indeed followed through
@@ -269,6 +278,7 @@ define([
269278
// Create a split button group
270279
_createSplitButton: function() {
271280
// create the new split button
281+
console.log("creating split button :" + this._buttonLabel);
272282
this.splitButton.innerHTML = this.buttonTitle;
273283
// if a glyphicon icon was requested: add the glyphicon to the button.
274284
if (this.buttonGlyphicon !== ''){

src/DropdownDivConverter/widget/ui/DropdownDivConverter.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
margin-left:0;
1111
}
1212

13-
.dropdown-div-converter .dropdown-menu {
13+
.dropdown-div-converter > .dropdown-menu {
1414
display: none;
1515
padding: 5px;
1616
}
1717

18-
.dropdown-div-converter.open .dropdown-menu {
18+
.dropdown-div-converter.open > .dropdown-menu {
1919
display: block;
2020
}
2121

src/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<package xmlns="http://www.mendix.com/package/1.0/">
3-
<clientModule name="DropdownDivConverter" version="1.4" xmlns="http://www.mendix.com/clientModule/1.0/">
3+
<clientModule name="DropdownDivConverter" version="1.5.0" xmlns="http://www.mendix.com/clientModule/1.0/">
44
<widgetFiles>
55
<widgetFile path="DropdownDivConverter/DropdownDivConverter.xml"/>
66
</widgetFiles>

test/Test.mpr

192 KB
Binary file not shown.

0 commit comments

Comments
 (0)