Bläddra i källkod

Merge branch 'feature/JSDoc' into 'wrdp'

Merge of feature/JSDoc to wrdp

See merge request o2oa/o2oa!2502
蔡祥熠 5 år sedan
förälder
incheckning
020fb18b0f

+ 1 - 2
o2web/jsdoc.conf.json

@@ -4,8 +4,7 @@
         "destination": "./o2web/jsdoc/",          // same as -d ./out/
         "recurse": true,                  // same as -r
         "template" : "./node_modules/ink-docstrap/template"
-        //"template": "templates/default"  // same as -t templates/default
-        //        "tutorials": "path/to/tutorials" // same as -u path/to/tutorials
+//        "tutorials": "./o2web/tutorials" // same as -u path/to/tutorials
     },
 
     "tags": {

+ 7 - 1
o2web/source/x_component_process_Xform/$Input.js

@@ -1,7 +1,8 @@
 MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
 /** @class $Input 组件类,此类为所有输入组件的父类
 * @extends MWF.xApplication.process.Xform.$Module
-*/
+ * @abstract
+ */
 MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class(
     /** @lends MWF.xApplication.process.Xform.$Input# */
     {
@@ -86,6 +87,11 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class(
                 if( this.json.showIcon!='no' && !this.form.json.hideModuleIcon ){
                     if (COMMON.Browser.safari) w = w-20;
                 }
+
+                /**
+                 * 描述信息节点,select\radio\checkbox无此节点,只读情况下无此节点.
+                 * @member {Element}
+                 */
                 this.descriptionNode = new Element("div", {"styles": this.form.css.descriptionNode, "text": this.json.description}).inject(this.node);
                 this.descriptionNode.setStyles({
                     "width": ""+w+"px",

+ 32 - 2
o2web/source/x_component_process_Xform/$Module.js

@@ -1,6 +1,7 @@
 
 MWF.require("MWF.widget.Common", null, false);
-/** @class $Module 组件类,此类为所有组件的父类。 */
+/** @class $Module 组件类,此类为所有组件的父类。
+ * @abstract*/
 MWF.xApplication.process.Xform.$Module = MWF.APP$Module =  new Class(
     /** @lends MWF.xApplication.process.Xform.$Module# */
     {
@@ -12,15 +13,34 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module =  new Class(
     initialize: function(node, json, form, options){
         /**
          * 组件的节点
-         * {@link https://mootools.net/core/docs/1.6.0/Element/Element MootoolsElement }
+         * @see https://mootools.net/core/docs/1.6.0/Element/Element
          * @member {Element}
+         * @example
+         *  //可以在脚本中获取该组件
+         * var field = this.form.get("fieldName"); //获取组件对象
+         * field.node.setStyle("font-size","12px"); //给节点设置样式
+         * @extends MWF.xApplication.process.Xform.$Input
          */
         this.node = $(node);
         this.node.store("module", this);
+
+        /**
+         * 组件的配置信息,比如id,类型等.
+         * @member {JsonObject}
+         * @example
+         *  //可以在脚本中获取该组件
+         * var json = this.form.get("fieldName").json; //获取组件对象
+         * var id = json.id; //获取组件的id
+         * var type = json.type; //获取组件的类型,如Textfield 为文本输入组件,Select为下拉组件
+         */
         this.json = json;
+
         /**
          * 组件的所在表单对象.
          * @member {MWF.xApplication.process.Xform.Form}
+         * @example
+         * var form = this.form.get("fieldName").form; //获取组件所在表单对象
+         * form.saveFormData(); //保存表单数据
          */
         this.form = form;
     },
@@ -33,12 +53,22 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module =  new Class(
         )) parent = parent.getParent();
         return (parent) ? parent.retrieve("module") : null;
     },
+    /**
+     * 隐藏组件.
+     * @example
+     * this.form.get("fieldName").hide(); //隐藏组件
+     */
     hide: function(){
         var dsp = this.node.getStyle("display");
         if (dsp!=="none") this.node.store("mwf_display", dsp);
         this.node.setStyle("display", "none");
         if (this.iconNode) this.iconNode.setStyle("display", "none");
     },
+    /**
+     * 显示组件.
+     * @example
+     * this.form.get("fieldName").show(); //显示组件
+     */
     show: function(){
         var dsp = this.node.retrieve("mwf_display", dsp);
         this.node.setStyle("display", dsp);

+ 44 - 1
o2web/source/x_component_process_Xform/Actionbar.js

@@ -1,11 +1,28 @@
 MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
 //MWF.require("MWF.widget.Tree", null, false);
 //MWF.require("MWF.widget.Toolbar", null, false);
-MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar =  new Class({
+
+/** @class Actionbar 操作条类。
+ * @example
+ * //可以在脚本中获取该组件
+ * //方法1:
+ * var actionbar = this.form.get("name"); //获取操作条
+ * //方法2
+ * var actionbar = this.target; //在操作条和操作本身的事件脚本中获取
+ * @extends MWF.xApplication.process.Xform.$Module
+ */
+MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar =  new Class(
+    /** @lends MWF.xApplication.process.Xform.Actionbar# */
+    {
 	Extends: MWF.APP$Module,
     options: {
         "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
     },
+    /**
+     * 重新加载操作条.
+     * @example
+     * this.form.get("name").reload(); //显示操作条
+     */
     reload : function(){
 	    this._loadUserInterface();
     },
@@ -201,6 +218,32 @@ MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar =  new Class({
             }
         }
     },
+    /**
+     * 根据操作id获取操作,该方法在操作条的afterLoad事件中有效,操作的操作脚本有效。
+     *  @param {string} id - 必选,操作id.
+     *  @return {o2.widget.ToolbarButton} 操作
+     *  @example
+     *  var actionbar = this.form.get("name"); //获取操作条
+     *  var item = actionbar.getItem( "action_delete" ); //获取删除操作
+     *  item.node.hide(); //隐藏删除操作的节点
+     *  item.node.click(); //触发操作的click事件
+     */
+    getItem : function( id ){
+        if( this.toolbarWidget && id ){
+            return this.toolbarWidget.items[id]
+        }
+    },
+    /**
+     * 获取所有操作,该方法在操作条的afterLoad事件中有效,操作的操作脚本有效。
+     *  @return {Array} 操作数组
+     *  @example
+     *  var actionbar = this.form.get("name"); //获取操作条
+     *  var itemList = actionbar.getAllItem(); //获取操作数组
+     *  itemList[1].node.hide(); //隐藏第一个操作
+     */
+    getAllItem : function(){
+        return this.toolbarWidget ? this.toolbarWidget.childrenButton : [];
+    },
     setToolbars: function(tools, node, readonly, noCondition){
         tools.each(function(tool){
             this.setToolbarItem(tool, node, readonly, noCondition);

+ 13 - 0
o2web/source/x_component_process_Xform/Textfield.js

@@ -1,5 +1,18 @@
 MWF.xDesktop.requireApp("process.Xform", "$Input", null, false);
 /** @class Textfield 文本输入框类。
+ * @example
+ * //可以在脚本中获取该组件
+ * //方法1:
+ * var field = this.form.get("fieldName"); //获取组件对象
+ * //方法2
+ * var field = this.target; //在组件本身的脚本中获取,比如事件脚本、默认值脚本、校验脚本等等
+ *
+ * var data = field.getData(); //获取值
+ * field.setData("字符串值"); //设置值
+ * field.hide(); //隐藏字段
+ * var id = field.json.id; //获取字段标识
+ * var flag = field.isEmpty(); //字段是否为空
+ * field.resetData();  //重置字段的值为默认值或置空
  * @extends MWF.xApplication.process.Xform.$Input
  */
 MWF.xApplication.process.Xform.Textfield = MWF.APPTextfield =  new Class({