[REF] web: calendar: allow disabling the delete button
In this commit, we add a new attribute "Delete" for user conveniency if he don't want 'Delete' button on popover card they easily achive by "delete=false" attribute and also add a testcase for it. task-id:2088954
This commit is contained in:
committed by
Simon Lejeune
parent
3dc7a7355e
commit
0052222b54
@@ -27,6 +27,7 @@ var CalendarPopover = Widget.extend(StandaloneFieldManagerMixin, {
|
||||
this.fields = eventInfo.fields;
|
||||
this.event = eventInfo.event;
|
||||
this.modelName = eventInfo.modelName;
|
||||
this.canDelete = eventInfo.canDelete;
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
|
||||
@@ -191,6 +191,7 @@ return AbstractRenderer.extend({
|
||||
this.color_map = {};
|
||||
this.hideDate = params.hideDate;
|
||||
this.hideTime = params.hideTime;
|
||||
this.canDelete = params.canDelete;
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
@@ -695,6 +696,7 @@ return AbstractRenderer.extend({
|
||||
displayFields: this.displayFields,
|
||||
event: eventData,
|
||||
modelName: this.model,
|
||||
canDelete: this.canDelete,
|
||||
};
|
||||
|
||||
var start = moment(eventData.r_start || eventData.start);
|
||||
|
||||
@@ -148,6 +148,7 @@ var CalendarView = AbstractView.extend({
|
||||
this.rendererParams.model = viewInfo.model;
|
||||
this.rendererParams.hideDate = utils.toBoolElse(attrs.hide_date || '', false);
|
||||
this.rendererParams.hideTime = utils.toBoolElse(attrs.hide_time || '', false);
|
||||
this.rendererParams.canDelete = this.controllerParams.activeActions.delete;
|
||||
|
||||
this.loadParams.fieldNames = _.uniq(fieldNames);
|
||||
this.loadParams.mapping = mapping;
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<ul class="list-group list-group-flush o_cw_popover_fields_secondary"/>
|
||||
<div class="card-footer border-top">
|
||||
<a href="#" class="btn btn-primary o_cw_popover_edit">Edit</a>
|
||||
<a href="#" class="btn btn-secondary o_cw_popover_delete ml-2">Delete</a>
|
||||
<a t-if="widget.canDelete" href="#" class="btn btn-secondary o_cw_popover_delete ml-2">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -247,6 +247,38 @@ QUnit.module('Views', {
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('delete attribute on calendar doesn\'t show delete button in popover', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const calendar = await createCalendarView({
|
||||
View: CalendarView,
|
||||
model: 'event',
|
||||
data: this.data,
|
||||
arch:
|
||||
'<calendar class="o_calendar_test" ' +
|
||||
'string="Events" ' +
|
||||
'event_open_popup="true" ' +
|
||||
'date_start="start" ' +
|
||||
'date_stop="stop" ' +
|
||||
'all_day="allday" ' +
|
||||
'delete="0" ' +
|
||||
'mode="month"/>',
|
||||
archs: archs,
|
||||
viewOptions: {
|
||||
initialDate: initialDate,
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.dom.click(calendar.$('.fc-event:contains(event 4) .fc-content'));
|
||||
|
||||
assert.containsOnce(calendar, '.o_cw_popover',
|
||||
"should open a popover clicking on event");
|
||||
assert.containsNone(calendar, '.o_cw_popover .o_cw_popover_delete',
|
||||
"should not have the 'Delete' Button");
|
||||
|
||||
calendar.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('breadcrumbs are updated with the displayed period', async function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
|
||||
@@ -913,6 +913,9 @@ calendar view are:
|
||||
``create``
|
||||
allows *dis*\ abling the corresponding action in the view by setting the
|
||||
corresponding attribute to ``false``
|
||||
``delete``
|
||||
allows *dis*\ abling the corresponding action in the view by setting the
|
||||
corresponding attribute to ``false``
|
||||
``<field>``
|
||||
declares fields to aggregate or to use in kanban *logic*. If the field is
|
||||
simply displayed in the calendar cards.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<rng:optional><rng:attribute name="hide_time"/></rng:optional>
|
||||
<rng:optional><rng:attribute name="hide_date"/></rng:optional>
|
||||
<rng:optional><rng:attribute name="create"/></rng:optional>
|
||||
<rng:optional><rng:attribute name="delete"/></rng:optional>
|
||||
<rng:optional>
|
||||
<rng:attribute name="mode">
|
||||
<rng:choice>
|
||||
|
||||
Reference in New Issue
Block a user