[FIX] web: Calendar: enter key not working in quick create
Before this commit, it was not possible to add a new event with the "quick create" if you pressed enter key instead of using confirm button.
This commit is contained in:
committed by
Aaron Bohy
parent
f624e8a575
commit
64e0fe80a3
@@ -31,6 +31,7 @@ var QuickCreate = Dialog.extend({
|
||||
|
||||
// Can hold data pre-set from where you clicked on agenda
|
||||
this.dataTemplate = dataTemplate || {};
|
||||
this.dataCalendar = dataCalendar;
|
||||
this.$input = $();
|
||||
|
||||
var self = this;
|
||||
@@ -68,7 +69,7 @@ var QuickCreate = Dialog.extend({
|
||||
this.$input = this.$('input').keyup(function enterHandler (e) {
|
||||
if(e.keyCode === $.ui.keyCode.ENTER) {
|
||||
self.$input.off('keyup', enterHandler);
|
||||
if (!self._quickAdd()){
|
||||
if (!self._quickAdd(self.dataCalendar)){
|
||||
self.$input.on('keyup', enterHandler);
|
||||
}
|
||||
} else if (e.keyCode === $.ui.keyCode.ESCAPE && self._buttons) {
|
||||
|
||||
@@ -214,7 +214,7 @@ QUnit.module('Views', {
|
||||
});
|
||||
|
||||
QUnit.test('create and change events', function (assert) {
|
||||
assert.expect(19);
|
||||
assert.expect(21);
|
||||
|
||||
var calendar = createView({
|
||||
View: CalendarView,
|
||||
@@ -272,6 +272,19 @@ QUnit.module('Views', {
|
||||
assert.strictEqual(calendar.$('.fc-event:contains(new event in quick create)').length, 1, "should display the new record");
|
||||
assert.strictEqual(calendar.$('td.fc-event-container[colspan]').length, 2, "should the new record have only one day");
|
||||
|
||||
// create a new event, quick create only (validated by pressing enter key)
|
||||
|
||||
testUtils.triggerMouseEvent($cell, "mousedown");
|
||||
testUtils.triggerMouseEvent($cell, "mouseup");
|
||||
|
||||
assert.ok($('.modal-dialog.modal-sm').length, "should open the quick create dialog");
|
||||
|
||||
$('.modal-body input:first')
|
||||
.val('new event in quick create validated by pressing enter key.')
|
||||
.trigger($.Event('keyup', {keyCode: $.ui.keyCode.ENTER}));
|
||||
|
||||
assert.strictEqual(calendar.$('.fc-event:contains(new event in quick create validated by pressing enter key.)').length, 1, "should display the new record");
|
||||
|
||||
// create a new event with 2 days
|
||||
|
||||
$cell = calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day:eq(2)');
|
||||
@@ -300,7 +313,7 @@ QUnit.module('Views', {
|
||||
$('.modal button.btn:contains(Ok)').trigger('click');
|
||||
assert.notOk(calendar.$('.fc-event:contains(event 4) .fc-content').length, "the record should be deleted");
|
||||
|
||||
assert.strictEqual(calendar.$('.fc-event-container .fc-event').length, 8, "should display 8 events");
|
||||
assert.strictEqual(calendar.$('.fc-event-container .fc-event').length, 9, "should display 9 events");
|
||||
// move to next month
|
||||
calendar.$buttons.find('.o_calendar_button_next').click();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user