Browse Source

publish muk_web_utils - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
39efbcfffc
  1. 2
      muk_web_utils/__manifest__.py
  2. 2
      muk_web_utils/static/src/js/fields/copy.js
  3. 8
      muk_web_utils/static/src/js/fields/share.js
  4. 184
      muk_web_utils/static/tests/fields.js
  5. 6
      muk_web_utils/template/assets.xml
  6. 20
      muk_web_utils/tests/__init__.py
  7. 36
      muk_web_utils/tests/test_js.py

2
muk_web_utils/__manifest__.py

@ -20,7 +20,7 @@
{ {
"name": "MuK Web Utils", "name": "MuK Web Utils",
"summary": """Utility Features""", "summary": """Utility Features""",
"version": "12.0.2.4.5",
"version": "12.0.2.4.6",
"category": "Extra Tools", "category": "Extra Tools",
"license": "AGPL-3", "license": "AGPL-3",
"author": "MuK IT", "author": "MuK IT",

2
muk_web_utils/static/src/js/fields/copy.js

@ -123,7 +123,7 @@ var BinaryFileCopy = fields.FieldBinaryFile.extend({
}, },
}); });
registry.add('binary_copy', BinaryFileCopy);
registry.add('copy_binary', BinaryFileCopy);
return { return {
BinaryFileCopy: BinaryFileCopy, BinaryFileCopy: BinaryFileCopy,

8
muk_web_utils/static/src/js/fields/share.js

@ -164,7 +164,9 @@ var BinaryFileShare = copy.BinaryFileCopy.extend(ShareMixin, {
fieldDependencies: _.extend({}, fields.FieldBinaryFile.prototype.fieldDependencies, { fieldDependencies: _.extend({}, fields.FieldBinaryFile.prototype.fieldDependencies, {
display_name: {type: 'char'}, display_name: {type: 'char'},
}), }),
events: _.extend({}, copy.BinaryFileCopy.prototype.events, ShareMixin.shareEvents),
events: _.extend({}, copy.BinaryFileCopy.prototype.events, ShareMixin.shareEvents, {
'click .mk_share_button': '_onShareDropdownClick',
}),
init: function () { init: function () {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.navigator = window.navigator.share; this.navigator = window.navigator.share;
@ -202,6 +204,10 @@ var BinaryFileShare = copy.BinaryFileCopy.extend(ShareMixin, {
share: !!this.shareUrl, share: !!this.shareUrl,
}))); })));
}, },
_onShareDropdownClick: function(event) {
$(event.currentTarget).dropdown("toggle");
event.stopPropagation();
},
}); });
registry.add('share_char', CharShare); registry.add('share_char', CharShare);

184
muk_web_utils/static/tests/fields.js

@ -0,0 +1,184 @@
odoo.define('muk_web_utils.tests.fields', function (require) {
"use strict";
var basicFields = require('web.basic_fields');
var concurrency = require('web.concurrency');
var config = require('web.config');
var core = require('web.core');
var FormView = require('web.FormView');
var KanbanView = require('web.KanbanView');
var ListView = require('web.ListView');
var session = require('web.session');
var testUtils = require('web.test_utils');
var field_registry = require('web.field_registry');
var createView = testUtils.createView;
var createAsyncView = testUtils.createAsyncView;
var DebouncedField = basicFields.DebouncedField;
var JournalDashboardGraph = basicFields.JournalDashboardGraph;
var _t = core._t;
QUnit.module('muk_web_utils', {}, function () {
QUnit.module('fields', {
beforeEach: function () {
this.data = {
partner: {
fields: {
display_name: {
string: "Displayed name",
type: "char",
searchable: true
},
short: {
string: "Short",
type: "char",
searchable: true,
trim: true
},
long: {
string: "Long",
string: "txt",
type: "text",
},
document: {
string: "Binary",
type: "binary",
attachment: true,
},
},
records: [{
id: 1,
display_name: "first record",
short: "Short Text",
long: "Super looooooong Text",
document: 'coucou==\n',
}],
},
};
}
}, function () {
QUnit.module('BinaryFileCopy');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<field name="document" widget="copy_binary" filename="short"/>' +
'<field name="short"/>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_copy_binary > .mk_copy_button').length,
1, "the copy button should be visible in readonly mode"
);
form.$buttons.find('.o_form_button_edit').click();
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_copy_binary').length,
0, "the copy button shouldn't be visible in edit mode"
);
form.destroy();
});
QUnit.module('CharShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<div>' +
'<field name="short" widget="share_char"/>' +
'</div>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('span.o_field_widget[name="short"] > .mk_share_dropdown.mk_share_char').length,
1, "the copy button should be visible in readonly mode"
);
form.destroy();
});
QUnit.module('TextShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(1);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<div>' +
'<field name="long" widget="share_text"/>' +
'</div>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('span.o_field_widget[name="long"] > .mk_share_dropdown.mk_share_text').length,
1, "the copy button should be visible in readonly mode"
);
form.destroy();
});
QUnit.module('BinaryFileShare');
QUnit.test('Fields is correctly rendered', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch: (
'<form string="Partners">' +
'<field name="document" widget="share_binary" filename="short"/>' +
'<field name="short"/>' +
'</form>'
),
res_id: 1,
});
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_share_dropdown > .mk_share_button').length,
1, "the share dropdown should be visible in readonly mode"
);
form.$buttons.find('.o_form_button_edit').click();
assert.strictEqual(
form.$('a.o_field_widget[name="document"] > .mk_share_dropdown > .mk_share_button').length,
0, "the share dropdown shouldn't be visible in edit mode"
);
form.destroy();
});
});
});
});

6
muk_web_utils/template/assets.xml

@ -53,4 +53,10 @@
</xpath> </xpath>
</template> </template>
<template id="qunit_suite" name="QUnit Assets" inherit_id="web.qunit_suite">
<xpath expr="//script[last()]" position="after">
<script type="text/javascript" src="/muk_web_utils/static/tests/fields.js" />
</xpath>
</template>
</odoo> </odoo>

20
muk_web_utils/tests/__init__.py

@ -0,0 +1,20 @@
###################################################################################
#
# Copyright (C) 2018 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
from . import test_js

36
muk_web_utils/tests/test_js.py

@ -0,0 +1,36 @@
###################################################################################
#
# Copyright (C) 2018 MuK IT GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###################################################################################
import os
import json
import logging
import requests
from odoo import _, http, tools, SUPERUSER_ID
from odoo.tests.common import HttpCase
from odoo.addons.muk_utils.tools.json import RecordEncoder
_path = os.path.dirname(os.path.dirname(__file__))
_logger = logging.getLogger(__name__)
class WebSuite(HttpCase):
def test_js(self):
self.browser_js('/web/tests?module=muk_web_utils&failfast', "", "", login='admin', timeout=1800)
Loading…
Cancel
Save