content_group_item.js 1.16 KB
Newer Older
1 2 3 4 5 6 7
/**
 * This class defines an controller view for content groups.
 * It renders an editor view or a details view depending on the state
 * of the underlying model.
 * It is expected to be backed by a Group model.
 */
define([
8
    'js/views/list_item', 'js/views/content_group_editor', 'js/views/content_group_details', 'gettext', "common/js/components/utils/view_utils"
9
], function(ListItemView, ContentGroupEditorView, ContentGroupDetailsView, gettext) {
10 11 12
    'use strict';

    var ContentGroupItemView = ListItemView.extend({
13 14 15 16
        events: {
            'click .delete': 'deleteItem'
        },

17 18
        tagName: 'section',

19 20
        baseClassName: 'content-group',

21 22 23 24 25 26 27 28 29 30 31
        canDelete: true,

        itemDisplayName: gettext('content group'),

        attributes: function () {
            return {
                'id': this.model.get('id'),
                'tabindex': -1
            };
        },

32 33 34 35 36 37 38 39 40 41 42
        createEditView: function() {
            return new ContentGroupEditorView({model: this.model});
        },

        createDetailsView: function() {
            return new ContentGroupDetailsView({model: this.model});
        }
    });

    return ContentGroupItemView;
});