Cleanup towards MKWS-363.
[mkws-moved-to-github.git] / src / mkws-widget.js
index d060e32..05e39ca 100644 (file)
@@ -13,7 +13,6 @@ mkws.makeWidget = function($, team, type, node) {
     config: mkws.objectInheritingFrom(team.config)
   };
 
-  that.log = team.log;
   that.trace = team.trace;
   that.debug = team.debug;
   that.info = team.info;
@@ -72,9 +71,13 @@ mkws.makeWidget = function($, team, type, node) {
   function expandValue(val) {
     if (val.match(/^!param!/)) {
       var param = val.replace(/^!param!/, '');
+      var optional = param.match(/^\?/);
+      if (optional) {
+        param = param.replace(/^\?/, ''); 
+      }
       val = mkws.getParameterByName(param);
       that.info("obtained val '" + val + "' from param '" + param + "'");
-      if (!val) {
+      if (!val && !optional) {
         alert("This page has a MasterKey widget that needs a val specified by the '" + param + "' parameter");
       }
     } else if (val.match(/^!path!/)) {
@@ -101,18 +104,6 @@ mkws.makeWidget = function($, team, type, node) {
     var that = this;
     var query = this.config.autosearch;
     if (query) {
-      var old = this.team.config.query;
-      if (!old) {
-        // Stash this for subsequent inspection
-        this.team.config.query = query;
-      } else if (old === query) {
-        this.warn("duplicate autosearch: '" + query + "': ignoring");
-        return;
-      } else {
-        this.warn("conflicting autosearch: '" + query + "' vs '" + old + "': ignoring");
-        return;
-      }
-
       this.team.queue("ready").subscribe(function() {
         // Postpone testing for the configuration items: these are not
         // yet set for Record subclass widgets that fill them in in the
@@ -183,7 +174,7 @@ mkws.makeWidget = function($, team, type, node) {
   if (fn) {
     fn.call(that);
     this.info("made " + type + " widget(node=" + node + ")");
-  } else if (type.match(/-Container-(narrow|wide)$/)) {
+  } else if (type.match(/-[Cc]ontainer-(narrow|wide)$/)) {
     // Not really a widget: no need to log its lack of promotion
   } else {
     this.info("made UNPROMOTED widget(type=" + type + ", node=" + node + ")");