/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/"; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 4); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = { async init() { if (this._initialized) return; this.init_config(); this.init_globals(); this._initialized = true; }, init_config() { this.config = { backend: 'sqlite', port: 8000 }; }, init_globals() { this.meta_cache = {}; this.docs = {}; this.flags = { cache_docs: false } }, add_to_cache(doc) { if (!this.flags.cache_docs) return; // add to `docs` cache if (doc.doctype && doc.name) { if (!this.docs[doc.doctype]) { this.docs[doc.doctype] = {}; } this.docs[doc.doctype][doc.name] = doc; } }, get_doc_from_cache(doctype, name) { if (this.docs[doctype] && this.docs[doctype][name]) { return this.docs[doctype][name]; } }, get_meta(doctype) { if (!this.meta_cache[doctype]) { this.meta_cache[doctype] = new (this.models.get_meta_class(doctype))(this.models.get('DocType', doctype)); } return this.meta_cache[doctype]; }, init_controller(doctype, module) { doctype = this.slug(doctype); this.models.controllers[doctype] = module[doctype]; this.models.meta_classes[doctype] = module[doctype + '_meta']; }, async get_doc(data, name) { if (typeof data==='string' && typeof name==='string') { let doc = this.get_doc_from_cache(data, name); if (!doc) { let controller_class = this.models.get_controller(data); doc = new controller_class({doctype:data, name: name}); await doc.load(); this.add_to_cache(doc); } return doc; } else { let controller_class = this.models.get_controller(data.doctype); var doc = new controller_class(data); } return doc; }, async get_new_doc(doctype) { let doc = await frappe.get_doc({doctype: doctype}); doc.set_name(); doc.__not_inserted = true; this.add_to_cache(doc); return doc; }, async insert(data) { const doc = await this.get_doc(data); return await doc.insert(); }, login(user='guest', user_key) { this.session = new this._session.Session(user); if (user && user_key) { this.authenticate(user_key); } }, close() { this.db.close(); if (this.server) { this.server.close(); } } }; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { const frappe = __webpack_require__(0); class BaseControl { constructor(docfield, parent) { Object.assign(this, docfield); if (!this.fieldname) { this.fieldname = frappe.slug(this.label); } this.parent = parent; if (this.setup) { this.setup(); } } bind(doc) { this.doc = doc; this.doc.add_handler(this.fieldname, () => { this.set_doc_value(); }); this.set_doc_value(); } refresh() { this.make(); this.set_doc_value(); } set_doc_value() { if (this.doc) { this.set_input_value(this.doc.get(this.fieldname)); } } make() { if (!this.form_group) { this.make_form_group(); this.make_label(); this.make_input(); this.set_input_name(); this.make_description(); this.bind_change_event(); } } make_form_group() { this.form_group = frappe.ui.add('div', 'form-group', this.parent); } make_label() { this.label_element = frappe.ui.add('label', null, this.form_group); this.label_element.textContent = this.label; } make_input() { this.input = frappe.ui.add('input', 'form-control', this.form_group); } set_input_name() { this.input.setAttribute('name', this.fieldname); } make_description() { if (this.description) { this.description_element = frappe.ui.add('small', 'form-text text-muted', this.form_group); this.description_element.textContent = this.description; } } set_input_value(value) { if (value === undefined || value === null) { value = ''; } this.input.value = value; } async get_input_value() { return await this.parse(this.input.value); } async parse(value) { return value; } async validate(value) { return value; } bind_change_event() { this.input.addEventListener('change', (e) => this.handle_change(e)); } async handle_change(e) { let value = await this.get_input_value(); value = await this.validate(value); await this.doc.set(this.fieldname, value); } } module.exports = BaseControl; /***/ }), /* 2 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { const frappe = __webpack_require__(0); class Document { constructor(data) { this.handlers = {}; this.setup(); Object.assign(this, data); } setup() { // add handlers } clear_handlers() { this.handlers = {}; } add_handler(key, method) { if (!this.handlers[key]) { this.handlers[key] = []; } this.handlers[key].push(method || key); } get(key) { return this[key]; } set(key, value) { this.validate_field(key, value); this[key] = value; } set_name() { // assign a random name by default // override this to set a name if (!this.name) { this.name = Math.random().toString(36).substr(3); } } set_keywords() { let keywords = []; for (let fieldname of this.meta.get_keyword_fields()) { keywords.push(this[fieldname]); } this.keywords = keywords.join(', '); } get meta() { if (!this._meta) { this._meta = frappe.get_meta(this.doctype); } return this._meta; } append(key, document) { if (!this[key]) { this[key] = []; } this[key].push(this.init_doc(document)); } init_doc(data) { if (data.prototype instanceof Document) { return data; } else { return new Document(d); } } validate_field (key, value) { let df = this.meta.get_field(key); if (df.fieldtype=='Select') { this.meta.validate_select(df, value); } } get_valid_dict() { let doc = {}; for(let df of this.meta.get_valid_fields()) { doc[df.fieldname] = this.get(df.fieldname); } return doc; } set_standard_values() { let now = new Date(); if (this.docstatus === null || this.docstatus === undefined) { this.docstatus = 0; } if (!this.owner) { this.owner = frappe.session.user; this.creation = now; } this.modified_by = frappe.session.user; this.modified = now; } async load() { let data = await frappe.db.get(this.doctype, this.name); if (data.name) { Object.assign(this, data); } else { throw new frappe.errors.NotFound(`Not Found: ${this.doctype} ${this.name}`); } } async insert() { this.set_name(); this.set_standard_values(); this.set_keywords(); await this.trigger('validate', 'before_insert'); await frappe.db.insert(this.doctype, this.get_valid_dict()); await this.trigger('after_insert', 'after_save'); } async delete() { await this.trigger('before_delete'); await frappe.db.delete(this.doctype, this.name); await this.trigger('after_delete'); } async trigger() { for(var key of arguments) { if (this.handlers[key]) { for (let method of this.handlers[key]) { if (typeof method === 'string') { await this[method](); } else { await method(this); } } } } } async update() { this.set_standard_values(); this.set_keywords(); await this.trigger('validate', 'before_update'); await frappe.db.update(this.doctype, this.get_valid_dict()); await this.trigger('after_update', 'after_save'); return this; } }; module.exports = { Document: Document }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(5); const client = __webpack_require__(10); // start server client.start({ server: 'localhost:8000', container: document.querySelector('.wrapper'), }).then(() => { frappe.todo_module = __webpack_require__(35); frappe.account_module = __webpack_require__(37); frappe.init_controller('account', frappe.account_module); frappe.init_controller('todo', frappe.todo_module); frappe.desk.add_sidebar_item('ToDo', '#list/todo'); frappe.desk.add_sidebar_item('Accounts', '#list/account'); frappe.router.default = '#list/todo'; frappe.router.show(window.location.hash); }); /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { // style-loader: Adds some css to the DOM by adding a