=== templates/macros.cs
==================================================================
|
|
|
|
| 179 | 179 | var c.name ?>" value="1" <?cs if c.selected ?>checked="checked"<?cs /if ?> /> |
| 180 | 180 | <label for="custom_<?cs var c.name ?>"><?cs alt c.label ?><?cs |
| 181 | 181 | var c.name ?><?cs /alt ?></label><?cs |
| | 182 | elif c.type == 'multi' ?> |
| | 183 | <div style="float: left"> |
| | 184 | <label for="custom_<?cs var c.name ?>"><?cs alt c.label ?><?cs |
| | 185 | var c.name ?><?cs /alt ?></label>: |
| | 186 | <?cs call:hdf_select_multiple(c.option, 'custom_'+c.name, 4) ?> |
| | 187 | </div><?cs |
| 182 | 188 | elif c.type == 'select' ?> |
| 183 | 189 | <select name="custom_<?cs var c.name ?>"><?cs each v = c.option ?> |
| 184 | 190 | <option <?cs if v.selected ?>selected="selected"<?cs /if ?>><?cs |
| 185 | | var v ?></option><?cs /each ?> |
| | 191 | var v.name ?></option><?cs /each ?> |
| 186 | 192 | </select><?cs |
| 187 | 193 | elif c.type == 'radio' ?> |
| 188 | 194 | <fieldset class="radio"> |
=== templates/query.cs
==================================================================
|
|
|
|
| 81 | 81 | </div> |
| 82 | 82 | <?cs if:len(query.custom) ?><?cs set:idx = 0 ?><?cs |
| 83 | 83 | each:custom = query.custom ?><?cs |
| 84 | | if:custom.type == 'select' || custom.type == 'radio' ?> |
| | 84 | if:custom.type == 'select' || custom.type == 'radio' || custom.type == 'multi' ?> |
| 85 | 85 | <?cs if:idx == 0 ?><br /><?cs /if ?><div> |
| 86 | 86 | <label for="<?cs var:custom.name ?>"><?cs var:custom.label ?></label> |
| 87 | 87 | <?cs call:hdf_select_multiple(custom.options, custom.name, 4) ?> |
=== trac/Query.py
==================================================================
|
|
|
|
| 129 | 129 | |
| 130 | 130 | custom_fields = get_custom_fields(self.env) |
| 131 | 131 | for custom in custom_fields: |
| 132 | | if custom['type'] == 'select' or custom['type'] == 'radio': |
| | 132 | if custom['type'] in ['select', 'radio', 'multi']: |
| 133 | 133 | check = constraints.has_key(custom['name']) |
| 134 | 134 | options = filter(None, custom['options']) |
| 135 | 135 | for i in range(len(options)): |
=== trac/Ticket.py
==================================================================
|
|
|
|
| 112 | 112 | *std_values) |
| 113 | 113 | id = db.db.sqlite_last_insert_rowid() |
| 114 | 114 | for name in custom_fields: |
| | 115 | value = self[name] |
| | 116 | if isinstance(value, list): |
| | 117 | value = '|'.join(value) |
| 115 | 118 | cursor.execute('INSERT INTO ticket_custom(ticket,name,value)' |
| 116 | | ' VALUES(%d, %s, %s)', id, name[7:], self[name]) |
| | 119 | ' VALUES(%d, %s, %s)', id, name[7:], value) |
| 117 | 120 | db.commit() |
| 118 | 121 | self['id'] = id |
| 119 | 122 | self._forget_changes() |
| … |
… |
|
| 144 | 147 | |
| 145 | 148 | |
| 146 | 149 | for name in self._old.keys(): |
| | 150 | newvalue = self[name] |
| 147 | 151 | if name[:7] == 'custom_': |
| 148 | 152 | fname = name[7:] |
| | 153 | if isinstance(newvalue, list): |
| | 154 | newvalue = '|'.join(newvalue) |
| 149 | 155 | cursor.execute('REPLACE INTO ticket_custom(ticket,name,value)' |
| 150 | | ' VALUES(%s, %s, %s)', id, fname, self[name]) |
| | 156 | ' VALUES(%s, %s, %s)', id, fname, newvalue) |
| 151 | 157 | else: |
| 152 | 158 | fname = name |
| 153 | 159 | cursor.execute ('UPDATE ticket SET %s=%s WHERE id=%s', |
| 154 | | fname, self[name], id) |
| | 160 | fname, newvalue, id) |
| 155 | 161 | |
| 156 | 162 | cursor.execute ('INSERT INTO ticket_change ' |
| 157 | 163 | '(ticket, time, author, field, oldvalue, newvalue) ' |
| 158 | 164 | 'VALUES (%s, %s, %s, %s, %s, %s)', |
| 159 | | id, when, author, fname, self._old[name], self[name]) |
| | 165 | id, when, author, fname, self._old[name], newvalue) |
| 160 | 166 | if comment: |
| 161 | 167 | cursor.execute ('INSERT INTO ticket_change ' |
| 162 | 168 | '(ticket,time,author,field,oldvalue,newvalue) ' |
| … |
… |
|
| 226 | 232 | 'label': items.get(name + '.label', ''), |
| 227 | 233 | 'value': items.get(name + '.value', '') |
| 228 | 234 | } |
| 229 | | if field['type'] == 'select' or field['type'] == 'radio': |
| | 235 | if field['type'] in ['multi', 'select', 'radio']: |
| 230 | 236 | field['options'] = items.get(name + '.options', '').split('|') |
| 231 | 237 | elif field['type'] == 'textarea': |
| 232 | 238 | field['width'] = items.get(name + '.cols', '') |
| … |
… |
|
| 248 | 254 | hdf.setValue('%s.type' % pfx, f['type']) |
| 249 | 255 | hdf.setValue('%s.label' % pfx, f['label']) |
| 250 | 256 | hdf.setValue('%s.value' % pfx, val) |
| 251 | | if f['type'] == 'select' or f['type'] == 'radio': |
| | 257 | if f['type'] in ['multi', 'select', 'radio']: |
| 252 | 258 | j = 0 |
| | 259 | if f['type'] == 'multi': |
| | 260 | multi = 1 |
| | 261 | val = val.split('|') # see Ticket.save_changes |
| 253 | 262 | for option in f['options']: |
| 254 | | hdf.setValue('%s.option.%d' % (pfx, j), option) |
| 255 | | if val and (option == val or str(j) == val): |
| 256 | | hdf.setValue('%s.option.%i.selected' % (pfx, j), '1') |
| | 263 | hdf.setValue('%s.option.%d.name' % (pfx, j), option) |
| | 264 | if val: |
| | 265 | if (multi and option in val) or (option == val or str(j) == val): |
| | 266 | hdf.setValue('%s.option.%i.selected' % (pfx, j), '1') |
| 257 | 267 | j += 1 |
| 258 | 268 | elif f['type'] == 'checkbox': |
| 259 | 269 | if val in util.TRUE: |