mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
added print format and code control
This commit is contained in:
parent
742b933207
commit
eac8bb3051
@ -61,8 +61,8 @@ module.exports = class mysqlDatabase extends Database{
|
||||
}
|
||||
|
||||
|
||||
async runAddColumnQuery(doctype) {
|
||||
await this.run(`ALTER TABLE ${doctype} ADD COLUMN ${this.get_column_definition(df)}`, values);
|
||||
async runAddColumnQuery(doctype, fields) {
|
||||
await this.run(`ALTER TABLE ${doctype} ADD COLUMN ${this.get_column_definition(doctype)}`);
|
||||
}
|
||||
|
||||
getOne(doctype, name, fields = '*') {
|
||||
|
0
client/desk/printpage.js
Normal file
0
client/desk/printpage.js
Normal file
@ -2,6 +2,8 @@
|
||||
@import "node_modules/awesomplete/awesomplete";
|
||||
@import "node_modules/flatpickr/dist/flatpickr";
|
||||
@import "node_modules/flatpickr/dist/themes/airbnb";
|
||||
@import "node_modules/codemirror/lib/codemirror";
|
||||
// @import "node_modules/codemirror/theme/cobalt";
|
||||
|
||||
$spacer-1: 0.25rem;
|
||||
$spacer-2: 0.5rem;
|
||||
@ -104,6 +106,13 @@ html {
|
||||
padding: $spacer-2 $spacer-3;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
font-family: "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;
|
||||
border: 1px solid $gray-300;
|
||||
border-radius: 0.25rem;
|
||||
padding: $spacer-2;
|
||||
}
|
||||
|
||||
.awesomplete {
|
||||
display: block;
|
||||
|
||||
@ -182,3 +191,4 @@ mark {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,12 +59,6 @@ class BaseControl {
|
||||
this.makeLabel();
|
||||
}
|
||||
this.makeInput();
|
||||
this.setInputName();
|
||||
this.setRequiredAttribute();
|
||||
this.setDisabled();
|
||||
if (!this.onlyInput) {
|
||||
this.makeDescription();
|
||||
}
|
||||
this.addChangeHandler();
|
||||
}
|
||||
|
||||
@ -82,6 +76,14 @@ class BaseControl {
|
||||
this.input = frappe.ui.add('input', 'form-control', this.getInputParent());
|
||||
this.input.autocomplete = "off";
|
||||
this.input.id = this.id;
|
||||
|
||||
this.setInputName();
|
||||
this.setRequiredAttribute();
|
||||
this.setDisabled();
|
||||
if (!this.onlyInput) {
|
||||
this.makeDescription();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setDisabled() {
|
||||
@ -124,7 +126,7 @@ class BaseControl {
|
||||
}
|
||||
|
||||
async getParsedValue() {
|
||||
return await this.parse(this.input.value);
|
||||
return await this.parse(this.getInputValue());
|
||||
}
|
||||
|
||||
getInputValue() {
|
||||
|
35
client/view/controls/code.js
Normal file
35
client/view/controls/code.js
Normal file
@ -0,0 +1,35 @@
|
||||
const BaseControl = require('./base');
|
||||
// const frappe = require('frappejs');
|
||||
const CodeMirror = require('codemirror');
|
||||
const modeHTML = require('codemirror/mode/htmlmixed/htmlmixed'); // eslint-disable-line
|
||||
const modeJavascript = require('codemirror/mode/javascript/javascript'); // eslint-disable-line
|
||||
|
||||
class CodeControl extends BaseControl {
|
||||
makeInput() {
|
||||
if (!this.options) {
|
||||
this.options = {};
|
||||
}
|
||||
this.options.theme = 'default';
|
||||
this.input = new CodeMirror(this.getInputParent(), this.options);
|
||||
}
|
||||
|
||||
setInputValue(value) {
|
||||
if (value !== this.input.getValue()) {
|
||||
this.input.setValue(value || '');
|
||||
}
|
||||
}
|
||||
|
||||
getInputValue(value) {
|
||||
return this.input.getValue();
|
||||
}
|
||||
|
||||
addChangeHandler() {
|
||||
this.input.on('blur', () => {
|
||||
if (this.skipChangeEvent) return;
|
||||
this.handleChange();
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports = CodeControl;
|
@ -1,4 +1,5 @@
|
||||
const controlClasses = {
|
||||
Code: require('./code'),
|
||||
Data: require('./data'),
|
||||
Date: require('./date'),
|
||||
Currency: require('./currency'),
|
||||
|
@ -4,13 +4,13 @@ module.exports = {
|
||||
file: './dist/js/bundle.js',
|
||||
format: 'iife',
|
||||
name: 'desk',
|
||||
globals: ['io']
|
||||
globals: ['io'] // for socketio client, which is imported directly
|
||||
},
|
||||
plugins: [
|
||||
require('rollup-plugin-commonjs')(),
|
||||
require('rollup-plugin-json')(),
|
||||
require('rollup-plugin-node-resolve')({
|
||||
preferBuiltins: true
|
||||
})
|
||||
}),
|
||||
],
|
||||
}
|
24
index.js
24
index.js
@ -106,12 +106,6 @@ module.exports = {
|
||||
return newDoc;
|
||||
},
|
||||
|
||||
newDoc(data) {
|
||||
let doc = new (this.getDocumentClass(data.doctype))(data);
|
||||
doc.setDefaults();
|
||||
return doc;
|
||||
},
|
||||
|
||||
async getNewDoc(doctype) {
|
||||
let doc = this.newDoc({doctype: doctype});
|
||||
doc._notInserted = true;
|
||||
@ -120,10 +114,28 @@ module.exports = {
|
||||
return doc;
|
||||
},
|
||||
|
||||
newDoc(data) {
|
||||
let doc = new (this.getDocumentClass(data.doctype))(data);
|
||||
doc.setDefaults();
|
||||
return doc;
|
||||
},
|
||||
|
||||
async insert(data) {
|
||||
return await (this.newDoc(data)).insert();
|
||||
},
|
||||
|
||||
async syncDoc(data) {
|
||||
let doc;
|
||||
if (await this.db.exists(data.doctype, data.name)) {
|
||||
doc = await this.getDoc(data.doctype, data.name);
|
||||
Object.assign(doc, data);
|
||||
await doc.update();
|
||||
} else {
|
||||
doc = this.newDoc(data);
|
||||
await doc.insert();
|
||||
}
|
||||
},
|
||||
|
||||
login(user='guest', user_key) {
|
||||
this.session = {user: user};
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ module.exports = {
|
||||
|
||||
// [doctype].json
|
||||
fs.mkdirSync(`./models/doctype/${name}`);
|
||||
fs.writeFileSync(`./models/doctype/${name}/${name}.js`, `{
|
||||
fs.writeFileSync(`./models/doctype/${name}/${name}.js`, `module.exports = {
|
||||
name: "${name}",
|
||||
doctype: "DocType",
|
||||
isSingle: 0,
|
||||
|
@ -22,10 +22,10 @@ module.exports = {
|
||||
],
|
||||
parent_fields: [
|
||||
{
|
||||
fieldname: 'owner', fieldtype: 'Text', required: 1
|
||||
fieldname: 'owner', fieldtype: 'Data', required: 1
|
||||
},
|
||||
{
|
||||
fieldname: 'modifieldBy', fieldtype: 'Text', required: 1
|
||||
fieldname: 'modifieldBy', fieldtype: 'Data', required: 1
|
||||
},
|
||||
{
|
||||
fieldname: 'creation', fieldtype: 'Datetime', required: 1
|
||||
@ -48,7 +48,7 @@ module.exports = {
|
||||
fieldname: 'parent', fieldtype: 'Data', required: 1
|
||||
},
|
||||
{
|
||||
fieldname: 'parenttype', fieldtype: 'Text', required: 1
|
||||
fieldname: 'parenttype', fieldtype: 'Data', required: 1
|
||||
},
|
||||
{
|
||||
fieldname: 'parentfield', fieldtype: 'Data', required: 1
|
||||
|
30
models/doctype/PrintFormat/PrintFormat.js
Normal file
30
models/doctype/PrintFormat/PrintFormat.js
Normal file
@ -0,0 +1,30 @@
|
||||
module.exports = {
|
||||
name: "PrintFormat",
|
||||
doctype: "DocType",
|
||||
isSingle: 0,
|
||||
isChild: 0,
|
||||
keywordFields: [],
|
||||
fields: [
|
||||
{
|
||||
fieldname: "name",
|
||||
label: "Name",
|
||||
fieldtype: "Data",
|
||||
required: 1
|
||||
},
|
||||
{
|
||||
fieldname: "for",
|
||||
label: "For",
|
||||
fieldtype: "Data",
|
||||
required: 1
|
||||
},
|
||||
{
|
||||
fieldname: "template",
|
||||
label: "Template",
|
||||
fieldtype: "Code",
|
||||
required: 1,
|
||||
options: {
|
||||
mode: 'text/html'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
module.exports = {
|
||||
NumberSeries: require('./doctype/NumberSeries/NumberSeries.js'),
|
||||
PrintFormat: require('./doctype/PrintFormat/PrintFormat.js'),
|
||||
Role: require('./doctype/Role/Role.js'),
|
||||
Session: require('./doctype/Session/Session.js'),
|
||||
SingleValue: require('./doctype/SingleValue/SingleValue.js'),
|
||||
|
@ -14,13 +14,14 @@
|
||||
"bootstrap": "^4.0.0",
|
||||
"bufferutil": "^3.0.3",
|
||||
"clusterize.js": "^0.18.0",
|
||||
"codemirror": "^5.35.0",
|
||||
"commander": "^2.13.0",
|
||||
"debug": "^3.1.0",
|
||||
"express": "^4.16.2",
|
||||
"flatpickr": "^4.3.2",
|
||||
"jquery": "^3.3.1",
|
||||
"mysql": "^2.15.0",
|
||||
"node-fetch": "^1.7.3",
|
||||
"nunjucks": "^3.1.0",
|
||||
"popper.js": "^1.12.9",
|
||||
"rollup-plugin-ignore": "^1.0.3",
|
||||
"socket.io": "^2.0.4",
|
||||
@ -57,6 +58,7 @@
|
||||
"rollup-plugin-node-globals": "^1.1.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.2",
|
||||
"rollup-plugin-postcss": "^1.2.7",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-sass": "^0.5.3"
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,11 @@ const rest_api = require('./rest_api');
|
||||
const frappeModels = require('frappejs/models');
|
||||
const common = require('frappejs/common');
|
||||
const bodyParser = require('body-parser');
|
||||
const fs = require('fs');
|
||||
|
||||
require.extensions['.html'] = function (module, filename) {
|
||||
module.exports = fs.readFileSync(filename, 'utf8');
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
async start({backend, connectionParams, models}) {
|
||||
|
1
utils/noop.js
Normal file
1
utils/noop.js
Normal file
@ -0,0 +1 @@
|
||||
module.exports = function () { return function () {}; };
|
59
yarn.lock
59
yarn.lock
@ -2,6 +2,10 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
a-sync-waterfall@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/a-sync-waterfall/-/a-sync-waterfall-1.0.0.tgz#38e8319d79379e24628845b53b96722b29e0e47c"
|
||||
|
||||
abbrev@1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
|
||||
@ -161,6 +165,10 @@ arrify@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
|
||||
|
||||
asap@^2.0.3:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||
|
||||
asn1.js@^4.0.0:
|
||||
version "4.9.2"
|
||||
resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.2.tgz#8117ef4f7ed87cd8f89044b5bff97ac243a16c9a"
|
||||
@ -517,7 +525,7 @@ camelcase-keys@^2.0.0:
|
||||
camelcase "^2.0.0"
|
||||
map-obj "^1.0.0"
|
||||
|
||||
camelcase@^2.0.0:
|
||||
camelcase@^2.0.0, camelcase@^2.0.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f"
|
||||
|
||||
@ -580,7 +588,7 @@ chardet@^0.4.0:
|
||||
version "0.4.2"
|
||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
|
||||
|
||||
chokidar@^1.7.0:
|
||||
chokidar@^1.6.0, chokidar@^1.7.0:
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
|
||||
dependencies:
|
||||
@ -630,7 +638,7 @@ cli-width@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
|
||||
|
||||
cliui@^3.2.0:
|
||||
cliui@^3.0.3, cliui@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d"
|
||||
dependencies:
|
||||
@ -664,6 +672,10 @@ code-point-at@^1.0.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
|
||||
|
||||
codemirror@^5.35.0:
|
||||
version "5.35.0"
|
||||
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.35.0.tgz#280653d495455bc66aa87e6284292b02775ba878"
|
||||
|
||||
color-convert@^1.3.0, color-convert@^1.9.0:
|
||||
version "1.9.1"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.1.tgz#c1261107aeb2f294ebffec9ed9ecad529a6097ed"
|
||||
@ -2815,6 +2827,17 @@ number-is-nan@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"
|
||||
|
||||
nunjucks@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/nunjucks/-/nunjucks-3.1.0.tgz#6c384eaafada1eb734d9a78126f3279c87d45d5e"
|
||||
dependencies:
|
||||
a-sync-waterfall "^1.0.0"
|
||||
asap "^2.0.3"
|
||||
postinstall-build "^5.0.1"
|
||||
yargs "^3.32.0"
|
||||
optionalDependencies:
|
||||
chokidar "^1.6.0"
|
||||
|
||||
oauth-sign@~0.8.1, oauth-sign@~0.8.2:
|
||||
version "0.8.2"
|
||||
resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"
|
||||
@ -3460,6 +3483,10 @@ postcss@^6.0.11, postcss@^6.0.13, postcss@^6.0.14, postcss@^6.0.16, postcss@^6.0
|
||||
source-map "^0.6.1"
|
||||
supports-color "^5.1.0"
|
||||
|
||||
postinstall-build@^5.0.1:
|
||||
version "5.0.1"
|
||||
resolved "https://registry.yarnpkg.com/postinstall-build/-/postinstall-build-5.0.1.tgz#b917a9079b26178d9a24af5a5cd8cb4a991d11b9"
|
||||
|
||||
prebuild-install@~2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.3.0.tgz#19481247df728b854ab57b187ce234211311b485"
|
||||
@ -4006,6 +4033,14 @@ rollup-plugin-postcss@^1.2.7:
|
||||
rollup-pluginutils "^2.0.1"
|
||||
style-inject "^0.2.0"
|
||||
|
||||
rollup-plugin-replace@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-replace/-/rollup-plugin-replace-2.0.0.tgz#19074089c8ed57184b8cc64e967a03d095119277"
|
||||
dependencies:
|
||||
magic-string "^0.22.4"
|
||||
minimatch "^3.0.2"
|
||||
rollup-pluginutils "^2.0.1"
|
||||
|
||||
rollup-plugin-sass@^0.5.3:
|
||||
version "0.5.3"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-sass/-/rollup-plugin-sass-0.5.3.tgz#f275ee19d40f4f915287dbf7fef92b9cd03c6181"
|
||||
@ -4732,6 +4767,10 @@ widest-line@^2.0.0:
|
||||
dependencies:
|
||||
string-width "^2.1.1"
|
||||
|
||||
window-size@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876"
|
||||
|
||||
wordwrap@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
|
||||
@ -4802,7 +4841,7 @@ xtend@~3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/xtend/-/xtend-3.0.0.tgz#5cce7407baf642cba7becda568111c493f59665a"
|
||||
|
||||
y18n@^3.2.1:
|
||||
y18n@^3.2.0, y18n@^3.2.1:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41"
|
||||
|
||||
@ -4816,6 +4855,18 @@ yargs-parser@^5.0.0:
|
||||
dependencies:
|
||||
camelcase "^3.0.0"
|
||||
|
||||
yargs@^3.32.0:
|
||||
version "3.32.0"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995"
|
||||
dependencies:
|
||||
camelcase "^2.0.1"
|
||||
cliui "^3.0.3"
|
||||
decamelize "^1.1.1"
|
||||
os-locale "^1.4.0"
|
||||
string-width "^1.0.1"
|
||||
window-size "^0.1.4"
|
||||
y18n "^3.2.0"
|
||||
|
||||
yargs@^7.0.0:
|
||||
version "7.1.0"
|
||||
resolved "https://registry.yarnpkg.com/yargs/-/yargs-7.1.0.tgz#6ba318eb16961727f5d284f8ea003e8d6154d0c8"
|
||||
|
Loading…
Reference in New Issue
Block a user