Subversion Repositories SmartDukaan

Rev

Rev 37175 | Rev 37182 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37175 Rev 37178
Line 238... Line 238...
238
        avContext.agendaOptions.forEach(function (opt) {
238
        avContext.agendaOptions.forEach(function (opt) {
239
            html += '<option value="' + opt + '"' + (preset[opt] ? ' selected' : '') + '>'
239
            html += '<option value="' + opt + '"' + (preset[opt] ? ' selected' : '') + '>'
240
                    + opt + (autoBadge[opt] ? ' ⚙' : '') + '</option>';
240
                    + opt + (autoBadge[opt] ? ' ⚙' : '') + '</option>';
241
        });
241
        });
242
        html += '</select>';
242
        html += '</select>';
-
 
243
        // Open-instance chips: AUTO = gear (metric-closed only), MANUAL = closable ✕.
-
 
244
        var chips = '';
-
 
245
        (p.openAgendas || []).forEach(function (oa) {
-
 
246
            chips += '<span class="label label-' + (oa.source === 'AUTO' ? 'warning' : 'default')
-
 
247
                    + '" style="margin-right:4px; display:inline-block; margin-top:3px;">'
-
 
248
                    + oa.label + (oa.source === 'AUTO'
-
 
249
                            ? ' ⚙'
-
 
250
                            : ' <a href="#" class="av-agenda-close" data-instanceid="' + oa.id
-
 
251
                              + '" style="color:#fff; text-decoration:none;" title="Close this agenda">&times;</a>')
-
 
252
                    + '</span>';
-
 
253
        });
-
 
254
        if (chips) html += '<div>' + chips + '</div>';
243
        return html;
255
        return html;
244
    }
256
    }
245
 
257
 
-
 
258
    // Close a MANUAL agenda instance from its chip.
-
 
259
    $(document).on('click', '.av-agenda-close', function (e) {
-
 
260
        e.preventDefault();
-
 
261
        var chip = $(this).closest('span');
-
 
262
        var iid = $(this).data('instanceid');
-
 
263
        var remark = prompt('Closing remark (optional):');
-
 
264
        if (remark === null) return; // cancelled
-
 
265
        $.ajax({
-
 
266
            url: context + '/beatPlan/agenda/close',
-
 
267
            type: 'POST',
-
 
268
            contentType: 'application/json',
-
 
269
            data: JSON.stringify({instanceId: iid, remark: remark})
-
 
270
        }).done(function () {
-
 
271
            chip.remove();
-
 
272
        }).fail(function (xhr) {
-
 
273
            alert('Close failed: ' + (xhr.responseText || xhr.statusText));
-
 
274
        });
-
 
275
    });
-
 
276
 
246
    var AGENDA_MULTISELECT_OPTS = {
277
    var AGENDA_MULTISELECT_OPTS = {
247
        includeSelectAllOption: false,
278
        includeSelectAllOption: false,
248
        maxHeight: 220,
279
        maxHeight: 220,
249
        buttonWidth: '240px',
280
        buttonWidth: '240px',
250
        numberDisplayed: 2,
281
        numberDisplayed: 2,