mokihi-js
v1.0.1
Published
An opensource package for ExtJS 6.2.0 GPL bundled with a collection of useful component wrapper functions.
Downloads
9
Maintainers
Readme
mokihi-js
MōkihiJS
An opensource package for ExtJS 6.2.0 GPL bundled with a collection of useful component wrapper functions.
This is the continuation of KonyvtarJS, bundled together with ExtJS 6.2.0 GPL instead of having it as another external lib, this package aims to provide both ExtJS 6.2.0 GPL and functionalities of KonyvtarJS as a single package for easy setup and ease of use.
Quickstart
Installation
$ npm install --save mokihi-js
Usage (NPM):
const Mokihi = require('mokihi-js');
Example (Using express and express-es6-template-engine):
@app.js
const express = require('express');
const es6Renderer = require('express-es6-template-engine');
const MokihiSetup = require('mokihi-js').setup;
const Mokihi = require('mokihi-js').core;
const app = express();
app.engine('html', es6Renderer);
app.set('views', 'views');
app.set('view engine', 'html');
app.get('/', function (req, res) {
res.render('template', {
locals: {
MokihiCss: MokihiSetup.loadExtJsCss(),
MokihiScript: MokihiSetup.loadExtJsScript(),
Mokihi
}
});
});
app.listen(3000);
@template.html
<!DOCTYPE html>
<html>
<head>
<style> ${MokihiCss} </style>
<script type="text/javascript"> ${MokihiScript} </script>
<script type="text/javascript"> var Mokihi = ${Mokihi}; </script>
</head>
<body>
</body>
</html>
Running Tests
DISCLAIMER
Available test cases are those that can be tested on the backend when calling Mokihi as an object, some functionalities dont have test cases since it is required to render a UI to load the ExtJS since it is a client side library and it does not support server side rendering.
Hence this package may or may not contain any bug upon release, if you ever encountered a bug please do report it immediately by creating an issue, or feel free to make a contribution instead.
$ npm test
Documentation
Table of Contents
Features
Component
- query
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'button',
* * reference: 'sample-button'
* * }
*
* * @Controller
* * Mokihi.component.query('button[reference = sample-button]');
*
* @param {string} queryString
*/
Mokihi.component.query(queryString);
- reference
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'button',
* * reference: 'sample-button'
* * }
*
* * @Controller
* * Mokihi.component.reference('button', 'sample-button');
*
* @param {string} component
* @param {string} reference
*/
Mokihi.component.reference(component, reference);
Ajax
- request
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.ajax.request('/login', 'POST', { user: john, pass: doe }, function (){}, function (){}, false);
*
* @param {string} url
* @param {string} method
* @param {object} params
* @param {function} sucessCallback
* @param {function} failureCallback
* @param {boolean} async
*/
Mokihi.ajax.request(url, method, params, sucessCallback, failureCallback, async);
- get
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.ajax.get('/login', { user: john, pass: doe }, function (){}, function (){}, false);
*
* @param {string} url
* @param {object} params
* @param {function} sucessCallback
* @param {function} failureCallback
* @param {boolean} async
*/
Mokihi.ajax.get(url, params, sucessCallback, failureCallback, async);
- post
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.ajax.post('/login', { user: john, pass: doe }, function (){}, function (){}, false);
*
* @param {string} url
* @param {object} params
* @param {function} sucessCallback
* @param {function} failureCallback
* @param {boolean} async
*/
Mokihi.ajax.post(url, params, sucessCallback, failureCallback, async);
- put
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.ajax.put('/login', { user: john, pass: doe }, function (){}, function (){}, false);
*
* @param {string} url
* @param {object} params
* @param {function} sucessCallback
* @param {function} failureCallback
* @param {boolean} async
*/
Mokihi.ajax.put(url, params, sucessCallback, failureCallback, async);
- delete
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.ajax.delete('/login', { user: john, pass: doe }, function (){}, function (){}, false);
*
* @param {string} url
* @param {object} params
* @param {function} sucessCallback
* @param {function} failureCallback
* @param {boolean} async
*/
Mokihi.ajax.delete(url, params, sucessCallback, failureCallback, async);
Url
- convertObjectToQuery
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.url.convertObjectToQuery({ user: john, pass: doe });
*
* @param {object} params
*/
Mokihi.url.convertObjectToQuery(params);
Button
- get
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'button',
* * reference: 'sample-button'
* * }
*
* * @Controller
* * Mokihi.button.get('sample-button');
*
* @param {string} reference
*/
Mokihi.button.get(reference);
- disable
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'button',
* * reference: 'sample-button'
* * }
*
* * @Controller
* * Mokihi.button.disable('sample-button');
*
* @param {string} reference
*/
Mokihi.button.disable(reference);
- enable
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'button',
* * reference: 'sample-button'
* * }
*
* * @Controller
* * Mokihi.button.enable('sample-button');
*
* @param {string} reference
*/
Mokihi.button.enable(reference);
Store
- create
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.store.create('/users', { active: true }, grid, true, 25);
*
* @param {string} url
* @param {object} extraParams
* @param {string} component
* @param {boolean} autoLoad
* @param {number} pageSize
*/
Mokihi.store.create(url, extraParams, component, autoLoad, pageSize);
- tree
/**
* * Sample Usage:
*
* * @Controller
* * Mokihi.store.tree('/menus', { userId: 2 }, grid, true, true);
*
* @param {string} url
* @param {object} extraParams
* @param {string} component
* @param {boolean} autoLoad
* @param {boolean} folderSort
*/
Mokihi.store.tree(url, extraParams, component, autoLoad, folderSort);
- local
/**
* * Sample Usage:
*
* * @Controller
* * var employees = [
* * { name: 'John Doe' },
* * { name: 'Jane Doe' }
* * ];
* * Mokihi.store.local(employees);
*
* @param {array} records
*/
Mokihi.store.local(records);
Combobox
- get
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'combobox',
* * reference: 'sample-combobox'
* * }
*
* * @Controller
* * Mokihi.combobox.get('sample-combobox');
*
* @param {string} reference
*/
Mokihi.combobox.get(reference);
- setup
/**
* * Sample Usage:
*
* * @View
* * {
* * xtype: 'combobox',
* * reference: 'sample-combobox'
* * }
*
* * @Controller
* * Mokihi.combobox.setup('sample-combobox', '/contries', { region: southeast });
*
* @param {string} reference
* @param {string} storeUrl
* @param {object} filters
*/
Mokihi.combobox.setup(reference, storeUrl, filters);
- getRecordById
/**
*
* * @View
* * {
* * xtype: 'combobox',
* * reference: 'sample-combobox'
* * }
*
* * @Controller
* * Sample Usage: Mokihi.combobox.getRecordById('sample-combobox', 2);
*
* @param {string} reference
* @param {number} id
*/
Mokihi.combobox.getRecordById(reference, id);
About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Related Projects
You might want to checkout these projects:
- NchikotaJS - An opensource tech stack composed of ExpressJS, NodeJS, ExtJS.
- PasserelleJS - An opensource API gateway built with ExpressJS.
- KonyvtarJS - An opensource library/package of code wrappers for ExtJS 6.2.0 GPL.
Author
Eagan Martin
License
Copyright © 2019, Eagan Martin. Release under the GPL-3.0 License