[REF] web,calendar: split calendar quick_add attr
Since the PR [1], quick_add can be both a boolean and an id: 0 = without quick create 1 = with quick create and simple dialog other number = with quick create and custom form view dialog This is not great to have both behavior in a same attribute so this commit split them back in two attributes as it was before [1]. It's easier to understand when we want a quick create and which view to use in the dialog. [1]: https://github.com/odoo/odoo/pull/122923 Part-of: odoo/odoo#138042
This commit is contained in:
@@ -359,7 +359,8 @@
|
||||
<calendar js_class="attendee_calendar" string="Meetings" date_start="start" date_stop="stop" date_delay="duration" all_day="allday"
|
||||
event_open_popup="true"
|
||||
event_limit="5"
|
||||
quick_add="%(calendar.view_calendar_event_form_quick_create)d"
|
||||
quick_add="1"
|
||||
quick_create_view_id="%(calendar.view_calendar_event_form_quick_create)d"
|
||||
color="partner_ids">
|
||||
<field name="location" invisible="not location" options="{'icon': 'fa fa-map-marker'}"/>
|
||||
<field name="attendees_count" invisible="1"/>
|
||||
|
||||
@@ -30,6 +30,7 @@ export class CalendarArchParser {
|
||||
let canCreate = true;
|
||||
let canDelete = true;
|
||||
let quickCreate = true;
|
||||
let quickCreateViewId = null;
|
||||
let hasEditDialog = false;
|
||||
let showUnusualDays = false;
|
||||
let isDateHidden = false;
|
||||
@@ -85,12 +86,11 @@ export class CalendarArchParser {
|
||||
}
|
||||
if (node.hasAttribute("quick_add")) {
|
||||
quickCreate = archParseBoolean(node.getAttribute("quick_add"), true);
|
||||
// quick_add could contain either false, true or an id for a form view
|
||||
if (quickCreate) {
|
||||
const viewId = parseInt(node.getAttribute("quick_add"), 10);
|
||||
if (viewId > 1) {
|
||||
quickCreate = viewId;
|
||||
}
|
||||
if (quickCreate && node.hasAttribute("quick_create_view_id")) {
|
||||
quickCreateViewId = parseInt(
|
||||
node.getAttribute("quick_create_view_id"),
|
||||
10
|
||||
);
|
||||
}
|
||||
}
|
||||
if (node.hasAttribute("event_open_popup")) {
|
||||
@@ -191,6 +191,7 @@ export class CalendarArchParser {
|
||||
formViewId,
|
||||
hasEditDialog,
|
||||
quickCreate,
|
||||
quickCreateViewId,
|
||||
isDateHidden,
|
||||
isTimeHidden,
|
||||
popoverFieldNodes,
|
||||
|
||||
@@ -107,7 +107,7 @@ export class CalendarModel extends Model {
|
||||
return this.meta.hasEditDialog;
|
||||
}
|
||||
get hasQuickCreate() {
|
||||
return Boolean(this.meta.quickCreate);
|
||||
return this.meta.quickCreate;
|
||||
}
|
||||
get isDateHidden() {
|
||||
return this.meta.isDateHidden;
|
||||
@@ -144,8 +144,7 @@ export class CalendarModel extends Model {
|
||||
}
|
||||
|
||||
get quickCreateFormViewId() {
|
||||
const quickCreate = parseInt(this.meta.quickCreate);
|
||||
return quickCreate ? quickCreate : false;
|
||||
return this.meta.quickCreateViewId;
|
||||
}
|
||||
|
||||
get defaultFilterLabel() {
|
||||
|
||||
@@ -35,6 +35,7 @@ QUnit.test("defaults", (assert) => {
|
||||
formViewId: false,
|
||||
hasEditDialog: false,
|
||||
quickCreate: true,
|
||||
quickCreateViewId: null,
|
||||
isDateHidden: false,
|
||||
isTimeHidden: false,
|
||||
popoverFieldNodes: {},
|
||||
@@ -95,7 +96,25 @@ QUnit.test("quickCreate", (assert) => {
|
||||
check(assert, "quick_add", "false", "quickCreate", false);
|
||||
check(assert, "quick_add", "False", "quickCreate", false);
|
||||
check(assert, "quick_add", "0", "quickCreate", false);
|
||||
check(assert, "quick_add", "12", "quickCreate", 12);
|
||||
check(assert, "quick_add", "12", "quickCreate", true);
|
||||
});
|
||||
|
||||
QUnit.test("quickCreateViewId", (assert) => {
|
||||
let arch = parseArch(
|
||||
`<calendar date_start="start_date" quick_add="0" quick_create_view_id="12" />`
|
||||
);
|
||||
assert.strictEqual(arch.quickCreate, false);
|
||||
assert.strictEqual(arch.quickCreateViewId, null);
|
||||
|
||||
arch = parseArch(
|
||||
`<calendar date_start="start_date" quick_add="1" quick_create_view_id="12" />`
|
||||
);
|
||||
assert.strictEqual(arch.quickCreate, true);
|
||||
assert.strictEqual(arch.quickCreateViewId, 12);
|
||||
|
||||
arch = parseArch(`<calendar date_start="start_date" quick_add="1"/>`);
|
||||
assert.strictEqual(arch.quickCreate, true);
|
||||
assert.strictEqual(arch.quickCreateViewId, null);
|
||||
});
|
||||
|
||||
QUnit.test("isDateHidden", (assert) => {
|
||||
|
||||
@@ -4703,7 +4703,7 @@ QUnit.module("Views", ({ beforeEach }) => {
|
||||
assert.containsOnce(target, ".fc-dayGridMonth-view");
|
||||
});
|
||||
|
||||
QUnit.test("calendar rendering with form view id being passed in quick_add", async (assert) => {
|
||||
QUnit.test("calendar with custom quick create view", async (assert) => {
|
||||
serviceRegistry.add(
|
||||
"dialog",
|
||||
makeFakeDialogService((className, props) => {
|
||||
@@ -4717,7 +4717,7 @@ QUnit.module("Views", ({ beforeEach }) => {
|
||||
resModel: "event",
|
||||
serverData,
|
||||
arch: `
|
||||
<calendar date_start="start" date_stop="stop" all_day="allday" mode="month" quick_add="2">
|
||||
<calendar date_start="start" date_stop="stop" all_day="allday" mode="month" quick_add="1" quick_create_view_id="2">
|
||||
<field name="name"/>
|
||||
</calendar>
|
||||
`,
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<rng:optional><rng:attribute name="event_limit" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="create_name_field" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="quick_add" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="quick_create_form_view_id" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="quick_create_view_id" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="color" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="event_open_popup" /></rng:optional>
|
||||
<rng:optional><rng:attribute name="show_unusual_days" /></rng:optional>
|
||||
|
||||
Reference in New Issue
Block a user