forked from Techsystech/web
[IMP] web_widget_text_markdown: black, isort, prettier
parent
5cdb172f17
commit
f1b55aabf5
|
@ -0,0 +1 @@
|
||||||
|
../../../../web_widget_text_markdown
|
|
@ -0,0 +1,6 @@
|
||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
|
@ -3,7 +3,7 @@
|
||||||
* Copyright 2017 Komit - <http:///komit-consulting.com>
|
* Copyright 2017 Komit - <http:///komit-consulting.com>
|
||||||
* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
||||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||||
odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
odoo.define("web_widget_text_markdown.FieldTextMarkDown", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var basic_fields = require("web.basic_fields");
|
var basic_fields = require("web.basic_fields");
|
||||||
|
@ -31,7 +31,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
CUST_LIBS_PATH + "web_widget_text_markdown.css",
|
CUST_LIBS_PATH + "web_widget_text_markdown.css",
|
||||||
],
|
],
|
||||||
|
|
||||||
_getValue: function() {
|
_getValue: function () {
|
||||||
var $widget = this.attrs.widget;
|
var $widget = this.attrs.widget;
|
||||||
var $type = this.field.type;
|
var $type = this.field.type;
|
||||||
if ($type === "html" && $widget && $widget === "bootstrap_markdown") {
|
if ($type === "html" && $widget && $widget === "bootstrap_markdown") {
|
||||||
|
@ -40,7 +40,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
return this.$markdown.getContent();
|
return this.$markdown.getContent();
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function () {
|
||||||
this._super();
|
this._super();
|
||||||
this.shw_render_html = new showdown.Converter({
|
this.shw_render_html = new showdown.Converter({
|
||||||
extensions: ["table", "footnotes", "toc"],
|
extensions: ["table", "footnotes", "toc"],
|
||||||
|
@ -78,10 +78,10 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_prepareInput: function() {
|
_prepareInput: function () {
|
||||||
var $input = this._super.apply(this, arguments);
|
var $input = this._super.apply(this, arguments);
|
||||||
_.defer(
|
_.defer(
|
||||||
function($elm) {
|
function ($elm) {
|
||||||
$input.removeClass(this.className);
|
$input.removeClass(this.className);
|
||||||
$input.wrap(
|
$input.wrap(
|
||||||
_.str.sprintf("<div class='%s'></div>", this.className)
|
_.str.sprintf("<div class='%s'></div>", this.className)
|
||||||
|
@ -94,15 +94,15 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
);
|
);
|
||||||
return $input;
|
return $input;
|
||||||
},
|
},
|
||||||
_getHtmlValue: function(value) {
|
_getHtmlValue: function (value) {
|
||||||
return this.shw_render_html.makeHtml(this._formatValue(value));
|
return this.shw_render_html.makeHtml(this._formatValue(value));
|
||||||
},
|
},
|
||||||
|
|
||||||
_renderReadonly: function() {
|
_renderReadonly: function () {
|
||||||
this.$el.html(this._getHtmlValue(this.value));
|
this.$el.html(this._getHtmlValue(this.value));
|
||||||
},
|
},
|
||||||
|
|
||||||
_getMarkdownOptions: function() {
|
_getMarkdownOptions: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var markdownOpts = {
|
var markdownOpts = {
|
||||||
iconlibrary: "fa",
|
iconlibrary: "fa",
|
||||||
|
@ -110,7 +110,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
width: "o_field_text_markdown",
|
width: "o_field_text_markdown",
|
||||||
savable: false,
|
savable: false,
|
||||||
language: this.getSession().user_context.lang,
|
language: this.getSession().user_context.lang,
|
||||||
onPreview: function(e) {
|
onPreview: function (e) {
|
||||||
var render_val = self._getHtmlValue(e.getContent());
|
var render_val = self._getHtmlValue(e.getContent());
|
||||||
return render_val;
|
return render_val;
|
||||||
},
|
},
|
||||||
|
@ -137,7 +137,7 @@ odoo.define("web_widget_text_markdown.FieldTextMarkDown", function(require) {
|
||||||
return markdownOpts;
|
return markdownOpts;
|
||||||
},
|
},
|
||||||
|
|
||||||
_markdownTranslate: function() {
|
_markdownTranslate: function () {
|
||||||
// Event is the click event from callback
|
// Event is the click event from callback
|
||||||
this._onTranslate(event);
|
this._onTranslate(event);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
/* Copyright 2019 Alexandre Díaz - <dev@redneboa.es>
|
||||||
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
* License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */
|
||||||
|
|
||||||
odoo.define("web_widget_text_markdown.test", function(require) {
|
odoo.define("web_widget_text_markdown.test", function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var FormView = require("web.FormView");
|
var FormView = require("web.FormView");
|
||||||
|
@ -13,7 +13,7 @@ odoo.define("web_widget_text_markdown.test", function(require) {
|
||||||
QUnit.module(
|
QUnit.module(
|
||||||
"web_widget_text_markdown",
|
"web_widget_text_markdown",
|
||||||
{
|
{
|
||||||
beforeEach: function() {
|
beforeEach: function () {
|
||||||
this.data = {
|
this.data = {
|
||||||
partner: {
|
partner: {
|
||||||
fields: {comment: {string: "Comment", type: "text"}},
|
fields: {comment: {string: "Comment", type: "text"}},
|
||||||
|
@ -27,11 +27,11 @@ odoo.define("web_widget_text_markdown.test", function(require) {
|
||||||
"</sheet></form>";
|
"</sheet></form>";
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
function() {
|
function () {
|
||||||
QUnit.module("FieldTextMarkDown");
|
QUnit.module("FieldTextMarkDown");
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
"bootstrap markdown widget are correctly rendered (preview)",
|
"bootstrap markdown widget are correctly rendered (preview)",
|
||||||
function(assert) {
|
function (assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
|
@ -42,8 +42,8 @@ odoo.define("web_widget_text_markdown.test", function(require) {
|
||||||
data: this.data,
|
data: this.data,
|
||||||
arch: this.arch,
|
arch: this.arch,
|
||||||
res_id: 1,
|
res_id: 1,
|
||||||
}).then(function(form) {
|
}).then(function (form) {
|
||||||
_.defer(function() {
|
_.defer(function () {
|
||||||
assert.strictEqual(form.$(".md-editor").length, 0);
|
assert.strictEqual(form.$(".md-editor").length, 0);
|
||||||
form.destroy();
|
form.destroy();
|
||||||
done();
|
done();
|
||||||
|
@ -53,7 +53,7 @@ odoo.define("web_widget_text_markdown.test", function(require) {
|
||||||
);
|
);
|
||||||
QUnit.test(
|
QUnit.test(
|
||||||
"bootstrap markdown widget are correctly rendered (edit)",
|
"bootstrap markdown widget are correctly rendered (edit)",
|
||||||
function(assert) {
|
function (assert) {
|
||||||
assert.expect(1);
|
assert.expect(1);
|
||||||
|
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
|
@ -65,8 +65,8 @@ odoo.define("web_widget_text_markdown.test", function(require) {
|
||||||
arch: this.arch,
|
arch: this.arch,
|
||||||
res_id: 1,
|
res_id: 1,
|
||||||
viewOptions: {mode: "edit"},
|
viewOptions: {mode: "edit"},
|
||||||
}).then(function(form) {
|
}).then(function (form) {
|
||||||
_.defer(function() {
|
_.defer(function () {
|
||||||
assert.strictEqual(form.$(".md-editor").length, 1);
|
assert.strictEqual(form.$(".md-editor").length, 1);
|
||||||
form.destroy();
|
form.destroy();
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Reference in New Issue