[REF] web: small linting pass, add some comments, update style
This commit is contained in:
committed by
Aaron Bohy
parent
0c1d9204c3
commit
7c41254d8f
@@ -53,9 +53,9 @@ var BasicView = AbstractView.extend({
|
||||
|
||||
var result = this._processFieldsView(arch, fields);
|
||||
var fieldAttrs = result.fieldAttrs;
|
||||
var view_fields = result.view_fields;
|
||||
var fieldNames = _.keys(view_fields);
|
||||
fields = _.defaults(view_fields, fields);
|
||||
var viewFields = result.view_fields;
|
||||
var fieldNames = _.keys(viewFields);
|
||||
fields = _.defaults(viewFields, fields);
|
||||
var self = this;
|
||||
// process the inner fields_view as well to find the fields they use.
|
||||
// register those fields' description directly on the view.
|
||||
@@ -63,12 +63,12 @@ var BasicView = AbstractView.extend({
|
||||
// basically the field_names will be the keys of the fields obj.
|
||||
// don't use _ to iterate on fields in case there is a 'length' field,
|
||||
// as _ doesn't behave correctly when there is a length key in the object
|
||||
for (var field_name in fields) {
|
||||
var field = fields[field_name];
|
||||
_.each(field.views, function (inner_fields_view) {
|
||||
result = self._processFieldsView(inner_fields_view.arch, inner_fields_view.fields);
|
||||
inner_fields_view.fieldAttrs = result.fieldAttrs;
|
||||
inner_fields_view.fields = result.view_fields;
|
||||
for (var fieldName in fields) {
|
||||
var field = fields[fieldName];
|
||||
_.each(field.views, function (innerFieldsView) {
|
||||
result = self._processFieldsView(innerFieldsView.arch, innerFieldsView.fields);
|
||||
innerFieldsView.fieldAttrs = result.fieldAttrs;
|
||||
innerFieldsView.fields = result.view_fields;
|
||||
});
|
||||
if (field.type === 'one2many' || field.type === 'many2many') {
|
||||
if (field.views && field.views.tree) {
|
||||
@@ -114,7 +114,7 @@ var BasicView = AbstractView.extend({
|
||||
*/
|
||||
_processFieldsView: function (arch, fields) {
|
||||
var self = this;
|
||||
var view_fields = Object.create(null);
|
||||
var viewFields = Object.create(null);
|
||||
var fieldAttrs = Object.create(null);
|
||||
traverse(arch, function (node) {
|
||||
if (typeof node === 'string') {
|
||||
@@ -124,14 +124,14 @@ var BasicView = AbstractView.extend({
|
||||
var attrs = node.attrs || {};
|
||||
var field = _.extend({}, fields[node.attrs.name]);
|
||||
self._processField(field, node, attrs);
|
||||
view_fields[node.attrs.name] = field;
|
||||
viewFields[node.attrs.name] = field;
|
||||
fieldAttrs[node.attrs.name] = attrs;
|
||||
return false;
|
||||
}
|
||||
return node.tag !== 'arch';
|
||||
});
|
||||
return {
|
||||
view_fields: view_fields,
|
||||
view_fields: viewFields,
|
||||
fieldAttrs: fieldAttrs,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -331,7 +331,7 @@ return AbstractModel.extend({
|
||||
*/
|
||||
_getFullCalendarOptions: function () {
|
||||
return {
|
||||
defaultView: (this.mode == "month")? "month" : ((this.mode === "week")? "agendaWeek" : ((this.mode === "day")? "agendaDay" : "agendaWeek")),
|
||||
defaultView: (this.mode === "month")? "month" : ((this.mode === "week")? "agendaWeek" : ((this.mode === "day")? "agendaDay" : "agendaWeek")),
|
||||
header: false,
|
||||
selectable: this.editable && this.create_right,
|
||||
selectHelper: true,
|
||||
|
||||
@@ -179,19 +179,18 @@ var FormController = BasicController.extend({
|
||||
options = options || {};
|
||||
var stayInEdit = 'stayInEdit' in options ? options.stayInEdit : false;
|
||||
var shouldReload = 'reload' in options ? options.reload : true;
|
||||
var db_id = this.handle;
|
||||
if (!this.model.isDirty(db_id) && !this.model.isNew(db_id)) {
|
||||
if (!this.model.isDirty(this.handle) && !this.model.isNew(this.handle)) {
|
||||
if (!stayInEdit) {
|
||||
this._toReadOnlyMode();
|
||||
}
|
||||
return $.Deferred().resolve();
|
||||
} else {
|
||||
var invalid_fields = this.renderer.checkInvalidFields();
|
||||
if (invalid_fields.length) {
|
||||
this._notifyInvalidFields(invalid_fields);
|
||||
var invalidFields = this.renderer.checkInvalidFields();
|
||||
if (invalidFields.length) {
|
||||
this._notifyInvalidFields(invalidFields);
|
||||
return $.Deferred().reject();
|
||||
} else {
|
||||
return this.model.save(db_id, {reload: shouldReload})
|
||||
return this.model.save(this.handle, {reload: shouldReload})
|
||||
.then(function (element) {
|
||||
if (!stayInEdit) {
|
||||
self._toReadOnlyMode();
|
||||
@@ -229,8 +228,7 @@ var FormController = BasicController.extend({
|
||||
_callButtonAction: function (attrs, record) {
|
||||
var self = this;
|
||||
var def = $.Deferred();
|
||||
var db_id = this.handle;
|
||||
record = record || this.model.get(db_id);
|
||||
record = record || this.model.get(this.handle);
|
||||
var recordID = record.data.id;
|
||||
this.trigger_up('execute_action', {
|
||||
action_data: _.extend({}, attrs, {
|
||||
|
||||
@@ -311,14 +311,14 @@ return BasicRenderer.extend({
|
||||
},
|
||||
_renderInnerField: function (node) {
|
||||
var field = this.state.fields[node.attrs.name];
|
||||
var field_descr = node.attrs.string || field.string;
|
||||
var fieldDescr = node.attrs.string || field.string;
|
||||
var hasLabel = !node.attrs.nolabel;
|
||||
var widget = this._renderFieldWidget(node);
|
||||
if (hasLabel) {
|
||||
var $label = $('<label>')
|
||||
.addClass('o_form_label')
|
||||
.attr('for', this._getIDForLabel(node.attrs.name))
|
||||
.text(field_descr);
|
||||
.text(fieldDescr);
|
||||
var isReadOnly = this.mode === 'readonly' || field.readonly;
|
||||
if (this.state.data.id && !widget.isSet() && isReadOnly) {
|
||||
$label.addClass('o_form_label_empty');
|
||||
@@ -356,8 +356,8 @@ return BasicRenderer.extend({
|
||||
var label = children[i];
|
||||
// If there is a "for" attribute, we expect to have an id concerned in the next node.
|
||||
if (label.attrs.for) {
|
||||
var linked_node = children[i+1];
|
||||
$result = this._renderInnerGroupLabel($result, label, linked_node);
|
||||
var linkedNode = children[i+1];
|
||||
$result = this._renderInnerGroupLabel($result, label, linkedNode);
|
||||
i++; // Skip the rendering of the next node because we just did it.
|
||||
} else {
|
||||
$result = this._renderInnerGroupLabel($result, label);
|
||||
@@ -369,10 +369,10 @@ return BasicRenderer.extend({
|
||||
}
|
||||
return $result;
|
||||
},
|
||||
_renderInnerGroupLabel: function ($result, label, linked_node) {
|
||||
_renderInnerGroupLabel: function ($result, label, linkedNode) {
|
||||
var $first = $('<td class="o_td_label">')
|
||||
.append(this._renderNode(label));
|
||||
var $second = linked_node ? $('<td>').append(this._renderNode(linked_node)) : $('<td>');
|
||||
var $second = linkedNode ? $('<td>').append(this._renderNode(linkedNode)) : $('<td>');
|
||||
var $tr = $('<tr>').append($first).append($second);
|
||||
return $result.append($tr);
|
||||
},
|
||||
@@ -464,10 +464,10 @@ return BasicRenderer.extend({
|
||||
},
|
||||
_renderTagGroup: function (node) {
|
||||
var self = this;
|
||||
var is_outer_group = _.some(node.children, function (child) {
|
||||
var isOuterGroup = _.some(node.children, function (child) {
|
||||
return child.tag === 'group';
|
||||
});
|
||||
if (!is_outer_group) {
|
||||
if (!isOuterGroup) {
|
||||
return this._renderInnerGroup(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ var RecordQuickCreate = quick_create.RecordQuickCreate;
|
||||
|
||||
var KanbanColumn = Widget.extend({
|
||||
template: "KanbanView.Group",
|
||||
|
||||
events: {
|
||||
'click .o_column_edit': 'edit_column',
|
||||
'click .o_column_delete': 'delete_column',
|
||||
@@ -25,14 +24,18 @@ var KanbanColumn = Widget.extend({
|
||||
'click .o_kanban_load_more': 'load_more',
|
||||
'click .o_kanban_toggle_fold': 'toggle_fold',
|
||||
},
|
||||
|
||||
custom_events: {
|
||||
'kanban_record_delete': 'delete_record',
|
||||
'cancel_quick_create': 'cancel_quick_create',
|
||||
'quick_create_add_record': 'quick_create_add_record',
|
||||
},
|
||||
|
||||
init: function (parent, data, options, record_options) {
|
||||
/**
|
||||
* @param {any} parent
|
||||
* @param {any} data
|
||||
* @param {any} options
|
||||
* @param {any} recordOptions
|
||||
*/
|
||||
init: function (parent, data, options, recordOptions) {
|
||||
this._super(parent);
|
||||
this.db_id = data.id;
|
||||
this.data_records = data.data;
|
||||
@@ -56,14 +59,14 @@ var KanbanColumn = Widget.extend({
|
||||
this.grouped_by_m2o = options.grouped_by_m2o;
|
||||
this.editable = options.editable;
|
||||
this.deletable = options.deletable;
|
||||
this.draggable = record_options.draggable;
|
||||
this.draggable = recordOptions.draggable;
|
||||
this.records_editable = options.records_editable;
|
||||
this.records_deletable = options.records_deletable;
|
||||
this.relation = options.relation;
|
||||
this.offset = 0;
|
||||
this.remaining = this.size - this.data_records.length;
|
||||
|
||||
this.record_options = _.extend(_.clone(record_options), {
|
||||
this.record_options = _.extend(_.clone(recordOptions), {
|
||||
group_info: this.values,
|
||||
});
|
||||
|
||||
@@ -76,7 +79,9 @@ var KanbanColumn = Widget.extend({
|
||||
this.tooltip_info = "";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
start: function () {
|
||||
var self = this;
|
||||
this.$header = this.$('.o_kanban_header');
|
||||
|
||||
@@ -621,10 +621,10 @@ ListRenderer.include({
|
||||
|
||||
// ignore clicks in modals, except if the list is in a modal, and the
|
||||
// click is performed in that modal
|
||||
var $list_modal = this.$el.closest('.modal');
|
||||
if ($list_modal.length) {
|
||||
var $listModal = this.$el.closest('.modal');
|
||||
if ($listModal.length) {
|
||||
var $click_modal = $(event.target).parents('.modal');
|
||||
if ($click_modal.prop('id') === $list_modal.prop('id')) {
|
||||
if ($click_modal.prop('id') === $listModal.prop('id')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,10 +358,10 @@ var ListRenderer = BasicRenderer.extend({
|
||||
* @returns {jQueryElement} a <tr> element
|
||||
*/
|
||||
_renderGroupRow: function (group) {
|
||||
var aggregate_values = _.mapObject(group.aggregateValues, function (value) {
|
||||
var aggregateValues = _.mapObject(group.aggregateValues, function (value) {
|
||||
return { value: value };
|
||||
});
|
||||
var $cells = this._renderAggregateCells(aggregate_values);
|
||||
var $cells = this._renderAggregateCells(aggregateValues);
|
||||
if (this.hasSelectors) {
|
||||
$cells.unshift($('<td>'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user