About ShowByCondition

0
Hi all, I have an issue about 'ShowByCondition' wedget as below. https://appstore.home.mendix.com/link/app/2539/ My desktopModeler version is 7.15.1 and I got a error message as below. The contents of this module seemed to be javascript. Does anyone have idea? Thank you in advance!  
asked
3 answers
2

Hi Toshiya,

We had a similar issue with a custom widget. I was able to get rid of could not create widget error by commenting out all of the logging in the javascript code. I didn't test if the widget still worked but you could give it a try.

https://drive.google.com/file/d/1I7wbg2ecSlD0fnCL5lRlWkUYA7dZ1yIl/view?usp=sharing

Hope this helps!

 

Edit: it gives me an error when I try to share it with you. 

"The administrator for apps.buildsystem.jp has disabled the ability to receive items from outside their domain. If those you're attempting to share with would like more information, they should contact their domain administrator directly."

 

Ill just post the javascript code and you can replace it in the .mpk file.

/*global logger*/
/*
    Default
    ========================

    @file      : ShowByCondition.js
    @version   : 1.2
    @author    : Remco
    @date      : Mon, 13 Jun 2016
    @copyright :
    @license   :

    Documentation
    ========================
    Describe your widget here.
*/

// Required module list. Remove unnecessary modules, you can always get them back from the boilerplate.
define([
    "dojo/_base/declare",
	"dojo/NodeList-traverse",
    "mxui/widget/_WidgetBase",
	"mxui/dom",
	"dojo/_base/lang",
], function(declare, NodeList, _WidgetBase, dom, lang) {
    "use strict";

    // Declare widget's prototype.
    return declare("ShowByCondition.widget.ShowByCondition", [ _WidgetBase ], {

        // Parameters configured in the Modeler.
		microflowName: "",
		returnValue: "",
		elementClassFalse: "",
		elementClassTrue: "",
		
		// Internal variables
		elementsToHide: [],

        // dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
        constructor: function() {
            // Uncomment the following line to enable debug messages
           // logger.level(logger.DEBUG);
           // logger.debug(this.id + ".constructor");
        },

        // dijit._WidgetBase.postCreate is called after constructing the widget. Implement to do extra setup work.
        postCreate: function() {
           // logger.debug(this.id + ".postCreate");
			
			if (this.elementClassFalse === "" && this.elementClassTrue === "") {
				this.domNode.parentElement.style.display = "none";
			}
        },

		setParentDisplay : function(display) {
			
			if (this.elementClassFalse === "" && this.elementClassTrue === "") {
				this.domNode.parentElement.style.display = "none";
				if (display == this.returnValue){
					this.domNode.parentElement.style.display = "block";
				}
			} else {
				var elementsToShow = this.domNode.parentElement.getElementsByClassName("hiddenByWidget");
				for(var i=0;i<elementsToShow.length; i++) {
					elementsToShow[i].classList.remove("hiddenByWidget");
				}
				
				if(display) {
					this.elementsToHide = this.domNode.parentElement.getElementsByClassName(this.elementClassTrue);
				} else {
					this.elementsToHide = this.domNode.parentElement.getElementsByClassName(this.elementClassFalse);
				}
				
				for(var i=0;i<this.elementsToHide.length; i++) {
					this.elementsToHide[i].className += " hiddenByWidget";
				}
			}
		},

        // mxui.widget._WidgetBase.update is called when context is changed or initialized. Implement to re-render and / or fetch data.
        update: function(obj, callback) {
			//logger.debug(this.id + ".update");
			this._contextObj = obj;
			this._resetSubscriptions();
			this._updateRendering();
            callback();
        },
		
		// Rerender the interface.
        _updateRendering: function () {
			if(this._contextObj) {
				if (this.microflowName != '') {
					mx.data.action({
						params: {
							applyto: "selection",
							actionname: this.microflowName,
							guids: [this._contextObj.getGuid()]
						},
						callback: dojo.hitch(this, function (result) {
							this.setParentDisplay(result);
						}),
						error: function(error) {
							alert(error.description);
						}
					}, this);
				}
			}
			
        },
        // Reset subscriptions.
        _resetSubscriptions: function () {
            var _objectHandle = null;
            // Release handles on previous object, if any.
            if (this._handles) {
                this._handles.forEach(function (handle, i) {
                    mx.data.unsubscribe(handle);
                });
                this._handles = [];
            }
            // When a mendix object exists create subscribtions. 
            if (this._contextObj) {
                _objectHandle = this.subscribe({
                    guid: this._contextObj.getGuid(),
                    callback: lang.hitch(this, function (guid) {
                        this._updateRendering();
                    })
                });
                this._handles = [_objectHandle];
            }
        },

        // mxui.widget._WidgetBase.uninitialize is called when the widget is destroyed. Implement to do special tear-down work.
        uninitialize: function() {
         // logger.debug(this.id + ".uninitialize");
            // Clean up listeners, helper objects, etc. There is no need to remove listeners added with this.connect / this.subscribe / this.own.
        },
    });
});

require(["ShowByCondition/widget/ShowByCondition"], function() {
    "use strict";
});

 

If you use 7zip to open the archive and navigate to the javascript file in the widget folder, you can open the javascript file and copy and paste the above code to replace it.

 

answered
2

Upgraded the widget on behalf of my colleague and it is published in the AppStore now!

answered
1

According to the reviews in the AppStore, the widget doesn't work in Mendix 7.14.1 and up.

You could file an issue on Github: https://github.com/remcos/ShowByCondition

or fix it yourself if you know how.

answered