collections.combo.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. collections.combo.FilterStatus = function(config) {
  2. config = config || {};
  3. Ext.applyIf(config,{
  4. store: [
  5. ['',_('collections.system.all')]
  6. ,['published',_('published')]
  7. ,['unpublished',_('unpublished')]
  8. ,['deleted',_('deleted')]
  9. ]
  10. ,name: 'filter'
  11. ,hiddenName: 'filter'
  12. ,triggerAction: 'all'
  13. ,editable: false
  14. ,selectOnFocus: false
  15. ,preventRender: true
  16. ,forceSelection: true
  17. ,enableKeyEvents: true
  18. });
  19. collections.combo.FilterStatus.superclass.constructor.call(this,config);
  20. };
  21. Ext.extend(collections.combo.FilterStatus,MODx.combo.ComboBox);
  22. Ext.reg('collections-combo-filter-status',collections.combo.FilterStatus);
  23. collections.combo.Template = function(config, getStore) {
  24. config = config || {};
  25. if (!config.clearBtnCls) {
  26. if (MODx.config.connector_url) {
  27. config.clearBtnCls = 'x-form-trigger';
  28. } else {
  29. config.clearBtnCls = null;
  30. }
  31. }
  32. if (!config.expandBtnCls) {
  33. if (MODx.config.connector_url) {
  34. config.expandBtnCls = 'x-form-trigger';
  35. } else {
  36. config.expandBtnCls = null;
  37. }
  38. }
  39. Ext.applyIf(config,{
  40. name: 'templates'
  41. ,hiddenName: 'templates[]'
  42. ,displayField: 'templatename'
  43. ,valueField: 'id'
  44. ,fields: ['templatename','id']
  45. ,mode: 'remote'
  46. ,triggerAction: 'all'
  47. ,typeAhead: true
  48. ,editable: true
  49. ,forceSelection: false
  50. ,pageSize: 20
  51. ,url: collections.config.connectorUrl
  52. ,baseParams: {
  53. action: 'mgr/extra/gettemplates'
  54. ,template: (MODx.request.id != undefined) ? MODx.request.id : 0
  55. ,addEmpty: 1
  56. }
  57. });
  58. Ext.applyIf(config,{
  59. store: new Ext.data.JsonStore({
  60. url: config.url
  61. ,root: 'results'
  62. ,totalProperty: 'total'
  63. ,fields: config.fields
  64. ,errorReader: MODx.util.JSONReader
  65. ,baseParams: config.baseParams || {}
  66. ,remoteSort: config.remoteSort || false
  67. ,autoDestroy: true
  68. })
  69. });
  70. if (getStore === true) {
  71. config.store.load();
  72. return config.store;
  73. }
  74. collections.combo.Template.superclass.constructor.call(this,config);
  75. this.config = config;
  76. return this;
  77. };
  78. Ext.extend(collections.combo.Template,Ext.ux.form.SuperBoxSelect);
  79. Ext.reg('collections-combo-template',collections.combo.Template);
  80. collections.combo.SortDir = function(config) {
  81. config = config || {};
  82. Ext.applyIf(config,{
  83. store: [
  84. ['asc',_('sort_asc')]
  85. ,['desc',_('sort_desc')]
  86. ]
  87. ,name: 'sortdir'
  88. ,hiddenName: 'sortdir'
  89. ,editable: false
  90. ,selectOnFocus: false
  91. ,preventRender: true
  92. ,forceSelection: true
  93. ,enableKeyEvents: true
  94. });
  95. collections.combo.SortDir.superclass.constructor.call(this,config);
  96. };
  97. Ext.extend(collections.combo.SortDir,MODx.combo.ComboBox);
  98. Ext.reg('collections-combo-sort-dir',collections.combo.SortDir);
  99. collections.combo.CollectionsTemplate = function(config) {
  100. config = config || {};
  101. Ext.applyIf(config,{
  102. name: 'collections_template'
  103. ,hiddenName: 'collections_template'
  104. ,displayField: 'name'
  105. ,valueField: 'id'
  106. ,fields: ['name','id']
  107. ,pageSize: 20
  108. ,url: collections.config.connectorUrl
  109. ,baseParams:{
  110. action: 'mgr/template/getlist'
  111. }
  112. });
  113. collections.combo.CollectionsTemplate.superclass.constructor.call(this,config);
  114. };
  115. Ext.extend(collections.combo.CollectionsTemplate,MODx.combo.ComboBox);
  116. Ext.reg('collections-combo-collections-template',collections.combo.CollectionsTemplate);
  117. collections.combo.SingleTemplate = function(config) {
  118. config = config || {};
  119. Ext.applyIf(config,{
  120. name: 'resource_template'
  121. ,hiddenName: 'resource_template'
  122. ,displayField: 'templatename'
  123. ,valueField: 'id'
  124. ,fields: ['templatename','id']
  125. ,pageSize: 20
  126. ,url: collections.config.connectorUrl
  127. ,baseParams:{
  128. action: 'mgr/extra/gettemplates'
  129. ,addEmpty: config.addEmpty | 0
  130. }
  131. });
  132. collections.combo.SingleTemplate.superclass.constructor.call(this,config);
  133. };
  134. Ext.extend(collections.combo.SingleTemplate,MODx.combo.ComboBox);
  135. Ext.reg('collections-combo-single-template',collections.combo.SingleTemplate);
  136. collections.combo.ContentPlace = function(config) {
  137. config = config || {};
  138. Ext.applyIf(config,{
  139. store: new Ext.data.SimpleStore({
  140. fields: ['d','v']
  141. ,data: [
  142. [_('collections.template.content_place_original') ,'original'],
  143. [_('collections.template.content_place_in_tab') ,'in-tab'],
  144. [_('collections.template.content_place_original_except_children') ,'original-except-children'],
  145. [_('collections.template.content_place_none') ,'none']
  146. ]
  147. })
  148. ,displayField: 'd'
  149. ,valueField: 'v'
  150. ,mode: 'local'
  151. ,value: 'original'
  152. ,triggerAction: 'all'
  153. ,editable: false
  154. ,selectOnFocus: false
  155. ,preventRender: true
  156. ,forceSelection: true
  157. ,enableKeyEvents: true
  158. });
  159. collections.combo.ContentPlace.superclass.constructor.call(this,config);
  160. };
  161. Ext.extend(collections.combo.ContentPlace,MODx.combo.ComboBox);
  162. Ext.reg('collections-combo-content-place',collections.combo.ContentPlace);
  163. collections.combo.Resource = function(config) {
  164. config = config || {};
  165. Ext.applyIf(config,{
  166. name: 'resource'
  167. ,hiddenName: 'resource'
  168. ,displayField: 'pagetitle'
  169. ,valueField: 'id'
  170. ,fields: ['pagetitle','id']
  171. ,pageSize: 20
  172. ,minChars: 1
  173. ,editable: true
  174. ,triggerAction: 'all'
  175. ,typeAhead: false
  176. ,forceSelection: true
  177. ,selectOnFocus: false
  178. ,url: collections.config.connectorUrl
  179. ,baseParams:{
  180. action: 'mgr/extra/getresources'
  181. }
  182. });
  183. collections.combo.Resource.superclass.constructor.call(this,config);
  184. };
  185. Ext.extend(collections.combo.Resource,MODx.combo.ComboBox);
  186. Ext.reg('collections-combo-resource',collections.combo.Resource);
  187. collections.combo.ViewFor = function(config) {
  188. config = config || {};
  189. Ext.applyIf(config,{
  190. store: new Ext.data.SimpleStore({
  191. fields: ['d','v']
  192. ,data: [
  193. [_('collections.template.view_for_all'), 0],
  194. [_('collections.template.view_for_collections'), 1],
  195. [_('collections.template.view_for_selections'), 2]
  196. ]
  197. })
  198. ,displayField: 'd'
  199. ,valueField: 'v'
  200. ,mode: 'local'
  201. ,value: 'view_for'
  202. ,triggerAction: 'all'
  203. ,editable: false
  204. ,selectOnFocus: false
  205. ,preventRender: true
  206. ,forceSelection: true
  207. ,enableKeyEvents: true
  208. });
  209. collections.combo.ViewFor.superclass.constructor.call(this,config);
  210. };
  211. Ext.extend(collections.combo.ViewFor,MODx.combo.ComboBox);
  212. Ext.reg('collections-combo-view-for',collections.combo.ViewFor);
  213. collections.combo.ExtendedBoolean = function(config) {
  214. config = config || {};
  215. Ext.applyIf(config,{
  216. store: new Ext.data.SimpleStore({
  217. fields: ['d','v']
  218. ,data: [
  219. [_('collections.global.use_default'),null]
  220. ,[_('yes'),true]
  221. ,[_('no'),false]
  222. ]
  223. })
  224. ,displayField: 'd'
  225. ,valueField: 'v'
  226. ,mode: 'local'
  227. ,triggerAction: 'all'
  228. ,editable: false
  229. ,selectOnFocus: false
  230. ,preventRender: true
  231. ,forceSelection: true
  232. ,enableKeyEvents: true
  233. });
  234. collections.combo.ExtendedBoolean.superclass.constructor.call(this,config);
  235. };
  236. Ext.extend(collections.combo.ExtendedBoolean,MODx.combo.ComboBox);
  237. Ext.reg('collections-combo-extended-boolean',collections.combo.ExtendedBoolean);
  238. collections.combo.ContentType = function(config) {
  239. config = config || {};
  240. Ext.applyIf(config,{
  241. name: 'content_type'
  242. ,hiddenName: 'content_type'
  243. ,displayField: 'name'
  244. ,valueField: 'id'
  245. ,fields: ['id', 'name']
  246. ,forceSelection: true
  247. ,typeAhead: false
  248. ,editable: false
  249. ,allowBlank: true
  250. ,pageSize: 20
  251. ,url: collections.config.connectorUrl
  252. ,baseParams: {
  253. action: 'mgr/extra/getcontenttypes'
  254. }
  255. });
  256. collections.combo.ContentType.superclass.constructor.call(this,config);
  257. };
  258. Ext.extend(collections.combo.ContentType,MODx.combo.ComboBox);
  259. Ext.reg('collections-combo-content-type',collections.combo.ContentType);
  260. collections.combo.ContentDispositionExtended = function(config) {
  261. config = config || {};
  262. Ext.applyIf(config,{
  263. store: new Ext.data.SimpleStore({
  264. fields: ['d','v']
  265. ,data: [
  266. [_('collections.global.use_default'),null]
  267. ,[_('inline'),0]
  268. ,[_('attachment'),1]
  269. ]
  270. })
  271. ,name: 'child_content_disposition'
  272. ,hiddenName: 'child_content_disposition'
  273. ,displayField: 'd'
  274. ,valueField: 'v'
  275. ,mode: 'local'
  276. ,triggerAction: 'all'
  277. ,editable: false
  278. ,pageSize: 20
  279. ,selectOnFocus: false
  280. ,preventRender: true
  281. });
  282. collections.combo.ContentDispositionExtended.superclass.constructor.call(this,config);
  283. };
  284. Ext.extend(collections.combo.ContentDispositionExtended,MODx.combo.ComboBox);
  285. Ext.reg('collections-combo-content-disposition-extended',collections.combo.ContentDispositionExtended);
  286. collections.combo.SortType = function(config) {
  287. config = config || {};
  288. Ext.applyIf(config,{
  289. store: new Ext.data.SimpleStore({
  290. fields: ['d','v']
  291. ,data: [
  292. [_('collections.template.sort_type_default'), null]
  293. ,[_('collections.template.sort_type_integer'), 'SIGNED INTEGER']
  294. ,[_('collections.template.sort_type_decimal'), 'DECIMAL']
  295. ,[_('collections.template.sort_type_datetime'), 'DATETIME']
  296. ]
  297. })
  298. ,name: 'sort_type'
  299. ,hiddenName: 'sort_type'
  300. ,displayField: 'd'
  301. ,valueField: 'v'
  302. ,mode: 'local'
  303. ,triggerAction: 'all'
  304. ,editable: false
  305. ,pageSize: 20
  306. ,selectOnFocus: false
  307. ,preventRender: true
  308. });
  309. collections.combo.SortType.superclass.constructor.call(this,config);
  310. };
  311. Ext.extend(collections.combo.SortType,MODx.combo.ComboBox);
  312. Ext.reg('collections-combo-sort-type',collections.combo.SortType);
  313. collections.combo.FredBlueprints = function(config) {
  314. config = config || {};
  315. Ext.applyIf(config,{
  316. name: 'blueprint',
  317. hiddenName: 'blueprint',
  318. displayField: 'name',
  319. valueField: 'uuid',
  320. fields: ['name','uuid', 'category_name', 'theme_name'],
  321. pageSize: 20,
  322. minChars: 1,
  323. editable: true,
  324. triggerAction: 'all',
  325. typeAhead: false,
  326. forceSelection: true,
  327. selectOnFocus: false,
  328. url: collections.config.connectorUrl,
  329. baseParams:{
  330. action: 'mgr/extra/fredgetblueprints',
  331. addNone: config.addNone || 0
  332. },
  333. tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name:htmlEncode}</span><br />',
  334. '<tpl if="category_name">Category: <span>{category_name:htmlEncode}</span><br />Theme: <span>{theme_name:htmlEncode}</span></tpl>',
  335. '</div></tpl>')
  336. });
  337. collections.combo.FredBlueprints.superclass.constructor.call(this,config);
  338. };
  339. Ext.extend(collections.combo.FredBlueprints,MODx.combo.ComboBox);
  340. Ext.reg('collections-combo-fred-blueprints',collections.combo.FredBlueprints);