想做一个更换主题的功能
第一步,做主题管理:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
<entity-model id="theme" name="theme" title="主题" enable-delete="true" enable-modity="true" version="2.0" cache-enabled="true"> <operations> <operation id="thememodelopadduuid" name="addTheme" title="新增" enable-delete="true" enable-modity="true" type="add" fixed-size="false" modal="true"> <condition-fields> <condition-field editable="false" hidden="false" field-id="theme_id" connect-mode="AND" /> </condition-fields> <operation-group id="addopbasicgroup" name="basicgroup" title="操作字段" enable-delete="true" enable-modity="true"> <operation-fields> <operation-field editable="false" hidden="true" field-id="theme_id" /> <operation-field editable="true" hidden="false" field-id="theme_code" /> <operation-field editable="true" hidden="false" field-id="theme_title" /> <operation-field editable="true" hidden="false" field-id="theme_css_path"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> <operation-field editable="true" hidden="false" field-id="theme_thumbnail"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> </operation-fields> </operation-group> </operation> <operation id="thememodelopupdateuuid" name="modifyTheme" title="修改" enable-delete="true" enable-modity="true" type="modify" fixed-size="false" modal="true"> <condition-fields> <condition-field editable="false" hidden="false" field-id="theme_id" connect-mode="AND" /> </condition-fields> <operation-group id="modifyopbasicgroup" name="basicgroup" title="操作字段" enable-delete="true" enable-modity="true"> <operation-fields> <operation-field editable="false" hidden="true" field-id="theme_id" /> <operation-field editable="true" hidden="false" field-id="theme_code" /> <operation-field editable="true" hidden="false" field-id="theme_title" /> <operation-field editable="true" hidden="false" field-id="theme_css_path"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> <operation-field editable="true" hidden="false" field-id="theme_thumbnail"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> </operation-fields> </operation-group> </operation> <operation id="thememodelopdeleteuuid" name="deleteTheme" title="删除" enable-delete="true" enable-modity="true" type="delete" fixed-size="false" modal="true"> <condition-fields> <condition-field editable="false" hidden="false" field-id="theme_id" connect-mode="AND" /> </condition-fields> <operation-group id="deleteopbasicgroup" name="basicgroup" title="操作字段" enable-delete="true" enable-modity="true"> <operation-fields> <operation-field editable="false" hidden="true" field-id="theme_id" /> <operation-field editable="true" hidden="false" field-id="theme_code" /> <operation-field editable="true" hidden="false" field-id="theme_title" /> <operation-field editable="true" hidden="false" field-id="theme_css_path" /> <operation-field editable="true" hidden="false" field-id="theme_thumbnail" /> </operation-fields> </operation-group> </operation> <operation id="thememodelopqueryuuid" name="viewTheme" title="查看" enable-delete="true" enable-modity="true" type="view" fixed-size="false" modal="true"> <condition-fields> <condition-field editable="false" hidden="false" field-id="theme_id" connect-mode="AND" /> </condition-fields> <operation-group id="viewopbasicgroup" name="basicgroup" title="操作字段" enable-delete="true" enable-modity="true"> <operation-fields> <operation-field editable="false" hidden="true" field-id="theme_id" /> <operation-field editable="true" hidden="false" field-id="theme_code" /> <operation-field editable="true" hidden="false" field-id="theme_title" /> <operation-field editable="true" hidden="false" field-id="theme_css_path"> <input-mode type="labelWholeLineMode"></input-mode> </operation-field> <operation-field editable="true" hidden="false" field-id="theme_thumbnail"> <input-mode type="labelWholeLineMode"></input-mode> </operation-field> </operation-fields> </operation-group> </operation> <operation id="thememodelopaddcopyuuid" name="copyAddTheme" title="拷贝新增" enable-delete="true" enable-modity="true" type="copyAdd" fixed-size="false" modal="true"> <condition-fields> <condition-field editable="false" hidden="false" field-id="theme_id" connect-mode="AND" /> </condition-fields> <operation-group id="copyAddopbasicgroup" name="basicgroup" title="操作字段" enable-delete="true" enable-modity="true"> <operation-fields> <operation-field editable="true" hidden="false" field-id="theme_code" /> <operation-field editable="true" hidden="false" field-id="theme_title" /> <operation-field editable="true" hidden="false" field-id="theme_css_path"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> <operation-field editable="true" hidden="false" field-id="theme_thumbnail"> <input-mode type="textWholeLineMode"></input-mode> </operation-field> </operation-fields> </operation-group> </operation> </operations> <views> <view id="thememodeloptableuuid" name="tabletheme" title="主题管理" enable-delete="true" enable-modity="true" type="table" page-size="10" allow-edit="false" allow-filter-front="false" fixed-size="false" modal="false" front-paging="false"> <view-groups> <view-group id="viewbasicgroup" name="basicgroup" title="基本信息" enable-delete="true" enable-modity="true"> <display-field editable="false" hidden="true" field-id="theme_id" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_code" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_title" aggregate-by-view="false" /> </view-group> </view-groups> <references> <operation-reference type="operation" id="thememodelopadduuid" /> <operation-reference type="operation" id="thememodelopaddcopyuuid" /> <operation-reference type="operation" id="thememodelopdeleteuuid" /> <operation-reference type="operation" id="thememodelopupdateuuid" /> <operation-reference type="operation" id="thememodelopqueryuuid" /> </references> </view> </views> <groups> <group id="basicgroup" name="basicgroup" title="基本字段" enable-delete="true" enable-modity="true"> <field standard-field-id="theme_id" primary="true" unique="true" display="false" not-null="false" auto-increase="false" editable="false" hidden="false" table-field="true" id="theme_id" /> <field standard-field-id="theme_code" primary="false" unique="false" display="false" not-null="false" auto-increase="false" editable="false" hidden="false" table-field="true" id="theme_code" /> <field standard-field-id="theme_title" primary="false" unique="false" display="false" not-null="false" auto-increase="false" editable="false" hidden="false" table-field="true" id="theme_title" /> <field standard-field-id="theme_css_path" primary="false" unique="false" display="false" not-null="false" auto-increase="false" editable="false" hidden="false" table-field="true" id="theme_css_path" /> <field standard-field-id="theme_thumbnail" primary="false" unique="false" display="false" not-null="false" auto-increase="false" editable="false" hidden="false" table-field="true" id="theme_thumbnail" /> </group> </groups> < /entity-model> |
OK,管理功能就算开发完毕了。
主窗口如下:
新增窗口如下:
复制新增如下:
修改窗口:
查看窗口:
删除确认窗口:
至此,通过配置xml,主题的管理功能开发完毕。
于是,增加数据,由于有拷贝新增,因此增加起来还是比较快速的。
第二步,做主题选择对话框:
增加一个新的view
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
<view id="thememodelopcarduuid" name="cardtheme" title="主题选择" enable-delete="true" enable-modity="true" type="card" page-size="0" allow-edit="false" allow-filter-front="true" fixed-size="false" modal="false" front-paging="false"> <customize-stage-configs> <customize-stage-config stage-name="card" view-path="/biz/theme/theme_card.page"> </customize-stage-config> </customize-stage-configs> <condition-fields> </condition-fields> <view-groups> <view-group id="viewbasicgroup" name="basicgroup" title="基本信息" enable-delete="true" enable-modity="true"> <display-field editable="false" hidden="true" field-id="theme_id" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_code" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_title" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_css_path" aggregate-by-view="false" /> <display-field editable="false" hidden="false" field-id="theme_thumbnail" aggregate-by-view="false" /> </view-group> </view-groups> < /view> |
编写视图中指定的模板文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#@wijDialog("${modelDefine.id}_${operationDefine.id}" "${operationDefine.title}") #foreach($bean in $modelProcessResult.beans) <a href="javascript:doChangeTheme('${TINY_CONTEXT_PATH}$bean.themeCssPath')"><img title="$bean.themeTitle" style="float:left;border:1px solid;margin:5px 5px;50pt;" src="${TINY_CONTEXT_PATH}$bean.themeThumbnail" /></a> #end #end < script> function doChangeTheme(path){ var list=$("link"); for(var i=0;i<list.length;i++){ var link=list.get(i); var pos=link.href.indexOf("/themes/"); if(pos>0){ pos=link.href.indexOf(contextPath+"/"); link.href=link.href.substr(0,pos)+ path; return; } } } < /script> |
至此开发任务完成,看一下模板选择界面
第三步,验证实际效果:
OK,收工。
操作录像:
http://sourceforge.net/projects/tinyorg/files/demo.mp4/download