[calendar] Improved 'Calendar Widget' definition way
authorDavid Baz Fayos <david.baz@openbravo.com>
Tue, 29 Jan 2013 02:02:59 +0100
changeset 19519 2fb100c6214e
parent 19518 121dac434766
child 19520 7c03514582ee
[calendar] Improved 'Calendar Widget' definition way
modules/org.openbravo.client.myob/src-db/database/sourcedata/OBKMO_WIDGET_CLASS.xml
modules/org.openbravo.client.myob/src/org/openbravo/client/myob/CalendarWidgetProvider.java
modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-calendar-widget.js
--- a/modules/org.openbravo.client.myob/src-db/database/sourcedata/OBKMO_WIDGET_CLASS.xml	Tue Jan 29 02:02:33 2013 +0100
+++ b/modules/org.openbravo.client.myob/src-db/database/sourcedata/OBKMO_WIDGET_CLASS.xml	Tue Jan 29 02:02:59 2013 +0100
@@ -72,6 +72,7 @@
 <!--F41E327965084556BCF7EC7B271603AA-->  <TITLE><![CDATA[Calendar Widget]]></TITLE>
 <!--F41E327965084556BCF7EC7B271603AA-->  <JAVACLASS><![CDATA[org.openbravo.client.myob.CalendarWidgetProvider]]></JAVACLASS>
 <!--F41E327965084556BCF7EC7B271603AA-->  <HEIGHT><![CDATA[500]]></HEIGHT>
+<!--F41E327965084556BCF7EC7B271603AA-->  <DESCRIPTION><![CDATA[This widget is work-in-progress and its API will change in the following months. Use it at your own risk.]]></DESCRIPTION>
 <!--F41E327965084556BCF7EC7B271603AA-->  <ALLOW_ANONYMOUS_ACCESS><![CDATA[N]]></ALLOW_ANONYMOUS_ACCESS>
 <!--F41E327965084556BCF7EC7B271603AA-->  <ISSUPERCLASS><![CDATA[Y]]></ISSUPERCLASS>
 <!--F41E327965084556BCF7EC7B271603AA-->  <CAN_MAXIMIZE><![CDATA[Y]]></CAN_MAXIMIZE>
--- a/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/CalendarWidgetProvider.java	Tue Jan 29 02:02:33 2013 +0100
+++ b/modules/org.openbravo.client.myob/src/org/openbravo/client/myob/CalendarWidgetProvider.java	Tue Jan 29 02:02:59 2013 +0100
@@ -19,9 +19,7 @@
 package org.openbravo.client.myob;
 
 import org.apache.log4j.Logger;
-import org.hibernate.criterion.Restrictions;
 import org.openbravo.client.kernel.KernelConstants;
-import org.openbravo.dal.service.OBDao;
 
 /**
  * Responsible for creating the Calendar Widget.
@@ -36,12 +34,9 @@
 
   @Override
   public String generate() {
-    final WidgetURL widgetURL = (WidgetURL) OBDao.getFilteredCriteria(WidgetURL.class,
-        Restrictions.eq(WidgetURL.PROPERTY_WIDGETCLASS, getWidgetClass())).uniqueResult();
-    String url = widgetURL.getURL();
     final String result = "isc.defineClass('" + KernelConstants.ID_PREFIX
         + getWidgetClass().getId() + "', isc.OBCalendarWidget).addProperties({widgetId: '"
-        + getWidgetClass().getId() + "', calendarProps: " + url + "});";
+        + getWidgetClass().getId() + "'});";
     return result;
   }
 
--- a/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-calendar-widget.js	Tue Jan 29 02:02:33 2013 +0100
+++ b/modules/org.openbravo.client.myob/web/org.openbravo.client.myob/js/ob-calendar-widget.js	Tue Jan 29 02:02:59 2013 +0100
@@ -24,13 +24,18 @@
   widgetInstanceId: null,
 
   createWindowContents: function () {
-    var layout, calendarProps = this.calendarProps;
+    var layout, calendarProps;
+    this.calendarProps = new Function('return ' + this.parameters.calendarProps)();
+    if (!this.calendarProps.isMultiCalendar && this.parameters.legendId) {
+      this.calendarProps.legendId = this.parameters.legendId;
+    }
+    calendarProps = this.calendarProps;
 
     if (!calendarProps) {
       return isc.VStack.create({
         members: [
         isc.Label.create({
-          contents: 'This widget must have an associated URL pointing to the object with the calendar properties'
+          contents: 'This widget must have a parameter "calendarProps" (DB Column Name) with a fixed value pointing to the object with the calendar properties'
         })]
       });
     }