mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[CLEANUP] update prettier to v2.0.4
This commit is contained in:
@@ -204,7 +204,7 @@ to be called in the constructor.
|
||||
class Counter extends owl.Component {
|
||||
static props = {
|
||||
initialValue: Number,
|
||||
optional: true
|
||||
optional: true,
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -217,7 +217,7 @@ to be called in the constructor.
|
||||
```js
|
||||
class Counter extends owl.Component {
|
||||
static defaultProps = {
|
||||
initialValue: 0
|
||||
initialValue: 0,
|
||||
};
|
||||
}
|
||||
```
|
||||
@@ -804,8 +804,8 @@ class RootNode extends Component {
|
||||
children: [
|
||||
{ label: "b" },
|
||||
{ label: "c", children: [{ label: "d" }, { label: "e" }] },
|
||||
{ label: "f", children: [{ label: "g" }] }
|
||||
]
|
||||
{ label: "f", children: [{ label: "g" }] },
|
||||
],
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
@@ -113,10 +113,10 @@ async function myEnv() {
|
||||
qweb: qweb,
|
||||
services: {
|
||||
localStorage: localStorage,
|
||||
rpc: rpc
|
||||
rpc: rpc,
|
||||
},
|
||||
debug: false,
|
||||
inMobileMode: true
|
||||
inMobileMode: true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ broadcasted to the application by an event on the `qweb` instance. It may be
|
||||
useful, for example, to log the error somewhere.
|
||||
|
||||
```js
|
||||
env.qweb.on("error", null, function(error) {
|
||||
env.qweb.on("error", null, function (error) {
|
||||
// do something
|
||||
// react to the error
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@ triggering events, and callbacks.
|
||||
```js
|
||||
const bus = new owl.core.EventBus();
|
||||
|
||||
bus.on("some-event", null, function(...args) {
|
||||
bus.on("some-event", null, function (...args) {
|
||||
console.log(...args);
|
||||
});
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ function useLoader() {
|
||||
}
|
||||
|
||||
onWillStart(() => updateRecord(component.props.id));
|
||||
onWillUpdateProps(nextProps => updateRecord(nextProps.id));
|
||||
onWillUpdateProps((nextProps) => updateRecord(nextProps.id));
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ For example:
|
||||
const translations = {
|
||||
hello: "bonjour",
|
||||
yes: "oui",
|
||||
no: "non"
|
||||
no: "non",
|
||||
};
|
||||
const translateFn = str => translations[str] || str;
|
||||
const translateFn = (str) => translations[str] || str;
|
||||
|
||||
const qweb = new QWeb({ translateFn });
|
||||
```
|
||||
|
||||
+14
-14
@@ -40,14 +40,14 @@ const actions = {
|
||||
state.todos.push({
|
||||
id: state.nextId++,
|
||||
message,
|
||||
isCompleted: false
|
||||
isCompleted: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const state = {
|
||||
todos: [],
|
||||
nextId: 1
|
||||
nextId: 1,
|
||||
};
|
||||
|
||||
const store = new owl.Store({ state, actions });
|
||||
@@ -90,7 +90,7 @@ const config = {
|
||||
state,
|
||||
actions,
|
||||
getters,
|
||||
env
|
||||
env,
|
||||
};
|
||||
const store = new Store(config);
|
||||
```
|
||||
@@ -110,7 +110,7 @@ const actions = {
|
||||
} catch (e) {
|
||||
state.loginState = "error";
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
@@ -144,7 +144,7 @@ const actions = {
|
||||
state.recordId = recordId;
|
||||
const data = await doSomeRPC("/read/", recordId);
|
||||
state.recordData = data;
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
@@ -159,7 +159,7 @@ const actions = {
|
||||
const data = await doSomeRPC("/read/", recordId);
|
||||
state.recordId = recordId;
|
||||
state.recordData = data;
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
@@ -187,14 +187,14 @@ transform the data contained in the store.
|
||||
```js
|
||||
const getters = {
|
||||
getPost({ state }, id) {
|
||||
const post = state.posts.find(p => p.id === id);
|
||||
const author = state.authors.find(a => a.id === post.id);
|
||||
const post = state.posts.find((p) => p.id === id);
|
||||
const author = state.authors.find((a) => a.id === post.id);
|
||||
return {
|
||||
id,
|
||||
author,
|
||||
content: post.content
|
||||
content: post.content,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// somewhere else
|
||||
@@ -224,11 +224,11 @@ Assume we have this store:
|
||||
const actions = {
|
||||
increment({ state }, val) {
|
||||
state.counter.value += val;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const state = {
|
||||
counter: { value: 0 }
|
||||
counter: { value: 0 },
|
||||
};
|
||||
const store = new owl.Store({ state, actions });
|
||||
```
|
||||
@@ -245,7 +245,7 @@ A counter component can then select this value and dispatch an action like this:
|
||||
|
||||
```js
|
||||
class Counter extends Component {
|
||||
counter = useStore(state => state.counter);
|
||||
counter = useStore((state) => state.counter);
|
||||
dispatch = useDispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ not ready yet, resolved directly otherwise). If called with a callback as
|
||||
argument, it executes it as soon as the DOM ready (or directly).
|
||||
|
||||
```js
|
||||
Promise.all([loadFile("templates.xml"), owl.utils.whenReady()]).then(function([templates]) {
|
||||
Promise.all([loadFile("templates.xml"), owl.utils.whenReady()]).then(function ([templates]) {
|
||||
const qweb = new owl.QWeb({ templates });
|
||||
const app = new App({ qweb });
|
||||
app.mount(document.body);
|
||||
@@ -29,7 +29,7 @@ Promise.all([loadFile("templates.xml"), owl.utils.whenReady()]).then(function([t
|
||||
or alternatively:
|
||||
|
||||
```js
|
||||
owl.utils.whenReady(function() {
|
||||
owl.utils.whenReady(function () {
|
||||
const qweb = new owl.QWeb();
|
||||
const app = new App({ qweb });
|
||||
app.mount(document.body);
|
||||
|
||||
Reference in New Issue
Block a user