mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[FIX] runbot: adapt js for 17.0
This commit is contained in:
parent
3b50f172c0
commit
8f34312967
@ -6,10 +6,11 @@ import { Many2OneField } from "@web/views/fields/many2one/many2one_field";
|
|||||||
|
|
||||||
import { _lt } from "@web/core/l10n/translation";
|
import { _lt } from "@web/core/l10n/translation";
|
||||||
import { registry } from "@web/core/registry";
|
import { registry } from "@web/core/registry";
|
||||||
import { useDynamicPlaceholder } from "@web/views/fields/dynamicplaceholder_hook";
|
import { useDynamicPlaceholder } from "@web/views/fields/dynamic_placeholder_hook";
|
||||||
import { useInputField } from "@web/views/fields/input_field_hook";
|
import { useInputField } from "@web/views/fields/input_field_hook";
|
||||||
|
|
||||||
import { onMounted, onWillUnmount, useEffect, useRef, xml, Component } from "@odoo/owl";
|
import { useRef, xml, Component } from "@odoo/owl";
|
||||||
|
import { useAutoresize } from "@web/core/utils/autoresize";
|
||||||
|
|
||||||
|
|
||||||
function stringify(obj) {
|
function stringify(obj) {
|
||||||
@ -30,39 +31,34 @@ export class JsonField extends TextField {
|
|||||||
t-att-id="props.id"
|
t-att-id="props.id"
|
||||||
t-att-placeholder="props.placeholder"
|
t-att-placeholder="props.placeholder"
|
||||||
t-att-rows="rowCount"
|
t-att-rows="rowCount"
|
||||||
t-on-input="onInput"
|
|
||||||
t-ref="textarea"
|
t-ref="textarea"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
`;
|
`;
|
||||||
setup() {
|
setup() {
|
||||||
if (this.props.dynamicPlaceholder) {
|
|
||||||
this.dynamicPlaceholder = useDynamicPlaceholder();
|
|
||||||
}
|
|
||||||
this.divRef = useRef("div");
|
this.divRef = useRef("div");
|
||||||
this.textareaRef = useRef("textarea");
|
this.textareaRef = useRef("textarea");
|
||||||
|
//if (this.props.dynamicPlaceholder) {
|
||||||
|
// this.dynamicPlaceholder = useDynamicPlaceholder(this.textareaRef);
|
||||||
|
//}
|
||||||
|
|
||||||
useInputField({
|
useInputField({
|
||||||
getValue: () => this.value,
|
getValue: () => this.value,
|
||||||
refName: "textarea",
|
refName: "textarea",
|
||||||
parse: JSON.parse,
|
parse: JSON.parse,
|
||||||
});
|
});
|
||||||
|
useAutoresize(this.textareaRef, { minimumHeight: 50 });
|
||||||
useEffect(() => {
|
|
||||||
if (!this.props.readonly) {
|
|
||||||
this.resize();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
onMounted(this.onMounted);
|
|
||||||
onWillUnmount(this.onWillUnmount);
|
|
||||||
}
|
}
|
||||||
get value() {
|
get value() {
|
||||||
return stringify(this.props.value || "");
|
return stringify(this.props.record.data[this.props.name] || "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.category("fields").add("jsonb", JsonField);
|
registry.category("fields").add("runbotjsonb", {
|
||||||
|
supportedTypes: ["jsonb"],
|
||||||
|
component: JsonField,
|
||||||
|
});
|
||||||
|
|
||||||
export class FrontendUrl extends Component {
|
export class FrontendUrl extends Component {
|
||||||
static template = xml`
|
static template = xml`
|
||||||
@ -84,7 +80,10 @@ export class FrontendUrl extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.category("fields").add("frontend_url", FrontendUrl);
|
registry.category("fields").add("frontend_url", {
|
||||||
|
supportedTypes: ["many2one"],
|
||||||
|
component: FrontendUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
export class FieldCharFrontendUrl extends Component {
|
export class FieldCharFrontendUrl extends Component {
|
||||||
@ -108,7 +107,10 @@ export class FieldCharFrontendUrl extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.category("fields").add("char_frontend_url", FieldCharFrontendUrl);
|
registry.category("fields").add("char_frontend_url", {
|
||||||
|
supportedTypes: ["char"],
|
||||||
|
component: FieldCharFrontendUrl,
|
||||||
|
});
|
||||||
|
|
||||||
//export class GithubTeamWidget extends CharField {
|
//export class GithubTeamWidget extends CharField {
|
||||||
|
|
||||||
|
@ -1,31 +1,42 @@
|
|||||||
/** @odoo-module **/
|
/** @odoo-module **/
|
||||||
|
import { patch } from "@web/core/utils/patch";
|
||||||
|
import { Message } from "@mail/core/common/message";
|
||||||
|
|
||||||
|
patch(Message.prototype, {
|
||||||
import { useState} from "@odoo/owl";
|
|
||||||
import { registerMessagingComponent, getMessagingComponent, unregisterMessagingComponent } from '@mail/utils/messaging_component';
|
|
||||||
|
|
||||||
const MailTrackingValue = getMessagingComponent('TrackingValue');
|
|
||||||
export class TrackingValue extends MailTrackingValue {
|
|
||||||
static template = 'runbot.TrackingValue'
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
this.display = useState({kept: false});
|
super.setup(...arguments);
|
||||||
super.setup()
|
this.kept = false;
|
||||||
this.oldValue = this.props.value.oldValue.formattedValueOrNone;
|
},
|
||||||
this.newValue = this.props.value.newValue.formattedValueOrNone;
|
isMultiline(trackingValue) {
|
||||||
this.multiline = (
|
console.log(trackingValue)
|
||||||
(this.oldValue && this.oldValue.includes('\n'))
|
const oldValue = trackingValue.oldValue.value;
|
||||||
&&
|
const newValue = trackingValue.newValue.value;
|
||||||
(this.newValue && this.newValue.includes('\n'))
|
return ((oldValue && oldValue.includes('\n')) && (newValue && newValue.includes('\n')))
|
||||||
)
|
},
|
||||||
if (this.multiline) {
|
formatTracking(trackingType, trackingValue) {
|
||||||
var diff = this.makeDiff(this.oldValue, this.newValue);
|
console.log('aaa')
|
||||||
this.lines = this.prepareForRendering(diff);
|
return super.formatTracking(trackingType, trackingValue)
|
||||||
}
|
},
|
||||||
}
|
|
||||||
toggleKept() {
|
toggleKept() {
|
||||||
this.display.kept = !this.display.kept;
|
this.kept = !this.kept;
|
||||||
}
|
},
|
||||||
|
copyOldToClipboard(trackingValue) {
|
||||||
|
return function () {
|
||||||
|
navigator.clipboard.writeText(trackingValue.oldValue.value);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
copyNewToClipboard(trackingValue) {
|
||||||
|
return function () {
|
||||||
|
navigator.clipboard.writeText(trackingValue.newValue.value);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
lines(trackingValue) {
|
||||||
|
const oldValue = trackingValue.oldValue.value;
|
||||||
|
const newValue = trackingValue.newValue.value;
|
||||||
|
const diff = this.makeDiff(oldValue, newValue);
|
||||||
|
const lines = this.prepareForRendering(diff);
|
||||||
|
return lines;
|
||||||
|
},
|
||||||
makeDiff(text1, text2) {
|
makeDiff(text1, text2) {
|
||||||
var dmp = new diff_match_patch();
|
var dmp = new diff_match_patch();
|
||||||
var a = dmp.diff_linesToChars_(text1, text2);
|
var a = dmp.diff_linesToChars_(text1, text2);
|
||||||
@ -36,7 +47,7 @@ export class TrackingValue extends MailTrackingValue {
|
|||||||
dmp.diff_charsToLines_(diffs, lineArray);
|
dmp.diff_charsToLines_(diffs, lineArray);
|
||||||
dmp.diff_cleanupSemantic(diffs);
|
dmp.diff_cleanupSemantic(diffs);
|
||||||
return diffs;
|
return diffs;
|
||||||
}
|
},
|
||||||
prepareForRendering(diffs) {
|
prepareForRendering(diffs) {
|
||||||
var lines = [];
|
var lines = [];
|
||||||
var pre_line_counter = 0
|
var pre_line_counter = 0
|
||||||
@ -66,16 +77,5 @@ export class TrackingValue extends MailTrackingValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
};
|
},
|
||||||
|
});
|
||||||
copyOldToClipboard() {
|
|
||||||
navigator.clipboard.writeText(this.oldValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
copyNewToClipboard() {
|
|
||||||
navigator.clipboard.writeText(this.newValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unregisterMessagingComponent({name:'TrackingValue'});
|
|
||||||
registerMessagingComponent(TrackingValue);
|
|
@ -1,32 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<templates>
|
<templates xml:space="preserve">
|
||||||
<t t-name="runbot.TrackingValue" owl="1">
|
<t t-inherit="mail.Message" t-inherit-mode="extension">
|
||||||
<div class="o_TrackingValue o_RunbotTrackingValue d-flex align-items-center flex-wrap mb-1" t-attf-class="{{ className }}" role="group" t-ref="root">
|
<xpath expr="//li[hasclass('o-mail-Message-tracking')]" position="replace">
|
||||||
<t t-if="multiline">
|
<li class="o-mail-Message-tracking mb-1" role="group">
|
||||||
<div class="btn-group btn-group-toggle mb-1">
|
<t t-if="isMultiline(trackingValue)">
|
||||||
<button class="btn btn-sm btn-outline-primary" t-on-click="copyOldToClipboard">Copy old value to clipboard</button>
|
<div class="btn-group btn-group-toggle mb-1">
|
||||||
<button class="btn btn-sm btn-outline-primary" t-on-click="toggleKept">Toggle context</button>
|
<button class="btn btn-sm btn-outline-primary" t-on-click="copyOldToClipboard(trackingValue)">Copy old value to clipboard</button>
|
||||||
<button class="btn btn-sm btn-outline-primary" t-on-click="copyNewToClipboard">Copy new value to clipboard</button>
|
<button class="btn btn-sm btn-outline-primary" t-on-click="toggleKept">Toggle context</button>
|
||||||
</div>
|
<button class="btn btn-sm btn-outline-primary" t-on-click="copyNewToClipboard(trackingValue)">Copy new value to clipboard</button>
|
||||||
<div class="o_TrackingValue_fieldName fst-italic text-muted ms-1 " t-esc="'(' + trackingValue.formattedChangedField + ')'"/>
|
</div>
|
||||||
<div class="code_diff">
|
<div class="o-mail-Message-trackingField ms-1 fst-italic text-muted">(<t t-esc="trackingValue.changedField"/>)</div>
|
||||||
<table>
|
<div class="code_diff">
|
||||||
<t t-foreach="lines" t-as="line" t-key="line_index">
|
<table>
|
||||||
<tr t-if="display.kept or line.type!=='kept'">
|
<t t-foreach="lines(trackingValue)" t-as="line" t-key="line_index">
|
||||||
<td class="col_number" t-esc="line.pre_line_counter"/>
|
<tr t-if="kept or line.type!=='kept'">
|
||||||
<td class="col_number" t-esc="line.post_line_counter"/>
|
<td class="col_number" t-esc="line.pre_line_counter"/>
|
||||||
<td class="code" t-att-class="line.type" t-esc="line.line"/>
|
<td class="col_number" t-esc="line.post_line_counter"/>
|
||||||
</tr>
|
<td class="code" t-att-class="line.type" t-esc="line.line"/>
|
||||||
</t>
|
</tr>
|
||||||
</table>
|
</t>
|
||||||
</div>
|
</table>
|
||||||
</t>
|
</div>
|
||||||
<t t-else="">
|
</t>
|
||||||
<span class="o_TrackingValue_oldValue me-1 px-1 text-muted fw-bold" t-esc="trackingValue.oldValue.formattedValueOrNone" t-att-class="{ 'fst-italic': !trackingValue.oldValue.formattedValue }"/>
|
<t t-else="">
|
||||||
<i class="o_TrackingValue_separator fa fa-long-arrow-right mx-1 text-600" title="Changed" role="img" aria-label="Changed"/>
|
<span class="o-mail-Message-trackingOld me-1 px-1 text-muted fw-bold" t-esc="formatTrackingOrNone(trackingValue.fieldType, trackingValue.oldValue)"/>
|
||||||
<span class="o_TrackingValue_newValue me-1 fw-bold text-info" t-esc="trackingValue.newValue.formattedValueOrNone" t-att-class="{ 'fst-italic': !trackingValue.newValue.formattedValue }"/>
|
<i class="o-mail-Message-trackingSeparator fa fa-long-arrow-right mx-1 text-600"/>
|
||||||
<span class="o_TrackingValue_fieldName fst-italic text-muted" t-esc="'(' + trackingValue.formattedChangedField + ')'"/>
|
<span class="o-mail-Message-trackingNew me-1 fw-bold text-info" t-esc="formatTrackingOrNone(trackingValue.fieldType, trackingValue.newValue)"/>
|
||||||
</t>
|
<span class="o-mail-Message-trackingField ms-1 fst-italic text-muted">(<t t-esc="trackingValue.changedField"/>)</span>
|
||||||
</div>
|
</t>
|
||||||
|
</li>
|
||||||
|
</xpath>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
@ -75,7 +75,7 @@
|
|||||||
<field name="trigger_id" domain="[('project_id', '=', parent.project_id)]"/>
|
<field name="trigger_id" domain="[('project_id', '=', parent.project_id)]"/>
|
||||||
<field name="config_id"/>
|
<field name="config_id"/>
|
||||||
<field name="extra_params"/>
|
<field name="extra_params"/>
|
||||||
<field name="config_data" widget="jsonb"/>
|
<field name="config_data" widget="runbotjsonb"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
@ -117,7 +117,7 @@
|
|||||||
<field name="trigger_id"/>
|
<field name="trigger_id"/>
|
||||||
<field name="config_id"/>
|
<field name="config_id"/>
|
||||||
<field name="extra_params"/>
|
<field name="extra_params"/>
|
||||||
<field name="config_data" widget="jsonb"/>
|
<field name="config_data" widget="runbotjsonb"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
Loading…
Reference in New Issue
Block a user