Skip to content

Commit

Permalink
merge @wq/template into @wq/jquery-mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Mar 5, 2020
1 parent 3798d88 commit 851fe0d
Show file tree
Hide file tree
Showing 25 changed files with 234 additions and 451 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ js_wq: js_build
cp -p packages/material/dist/material.js* js/wq/
cp -p packages/model/dist/model.js* js/wq/
cp -p packages/outbox/dist/outbox.js* js/wq/
cp -p packages/app/dist/patterns.js* js/wq/
cp -p packages/app/dist/photos.js* js/wq/
cp -p packages/router/dist/router.js* js/wq/
cp -p packages/app/dist/spinner.js* js/wq/
cp -p packages/store/dist/store.js* js/wq/
cp -p packages/template/dist/template.js* js/wq/

js_leaflet_draw:
echo "define(['leaflet'], function(L) {" > js/leaflet.draw.js
Expand Down Expand Up @@ -56,7 +52,7 @@ js_lib: js_build js_leaflet_draw js_regenerator_runtime
sed -i "s/'exports'/'exports', 'leaflet'/" js/leaflet.markercluster.js
cp -p packages/leaflet/node_modules/leaflet.wms/dist/leaflet.wms.js js/leaflet.wms.js
cp -p packages/store/node_modules/localforage/dist/localforage.js js/localforage.js
cp -p packages/template/node_modules/mustache/mustache.js js/mustache.js
cp -p packages/jquery-mobile/node_modules/mustache/mustache.js js/mustache.js
cp -p node_modules/requirejs/require.js js/require.js

css: init
Expand Down
4 changes: 1 addition & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module.exports = {
plugins: [
'@babel/plugin-proposal-class-properties'
],
plugins: ['@babel/plugin-proposal-class-properties'],
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-react'
Expand Down
3 changes: 0 additions & 3 deletions packages/app/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import app from './src/app.js';
import photos from './src/photos.js';
import patterns from './src/patterns.js';

export default app;
export { app, photos, patterns };
86 changes: 37 additions & 49 deletions packages/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"@wq/outbox": "^1.2.0",
"@wq/router": "^1.2.0",
"@wq/store": "^1.2.0",
"@wq/template": "^1.2.0",
"localforage": "^1.7.3"
"mustache": "^4.0.0"
},
"devDependencies": {
"@wq/jquery-mobile": "^1.2.0",
Expand Down
57 changes: 7 additions & 50 deletions packages/app/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,17 @@ import {
babelAMD,
outputAMD
} from '../../rollup-utils.js';
const banners = {
app: makeBanner(pkg, 2012),
patterns: makeBanner(
{
name: pkg.name + '/patterns',
description:
'wq/app.js plugin to handle dynamically adding nested forms',
version: pkg.version
},
2016
),
photos: makeBanner(
{
name: pkg.name + '/photos',
description: 'Helpers for working with Cordova photo library',
version: pkg.version
},
2012
),
spinner: makeBanner(
{
name: pkg.name + '/spinner',
description: "Wrapper for jQuery Mobile's spinner",
version: pkg.version
},
2012
)
};
const banner = makeBanner(pkg, 2012);

export default [
// ESM
{
input: 'packages/app/index.js',
plugins: [wqDeps('@wq'), babelNPM()],
external: ['localforage'],
external: ['mustache'],
output: [
{
banner: banners.app,
banner,
file: 'packages/app/dist/index.es.js',
format: 'esm'
}
Expand All @@ -53,10 +26,10 @@ export default [
{
input: 'packages/app/index.js',
plugins: [wqDeps('@wq'), babelNPM()],
external: ['localforage'],
external: ['mustache'],
output: [
{
banner: banners.app,
banner,
file: 'packages/app/dist/index.js',
format: 'cjs',
exports: 'named'
Expand All @@ -67,23 +40,7 @@ export default [
{
input: 'packages/app/src/app.js',
plugins: [wqDeps(), babelAMD()],
external: ['./spinner'],
output: outputAMD('app', banners.app)
},
{
input: 'packages/app/src/patterns.js',
plugins: [wqDeps(), babelAMD()],
output: outputAMD('patterns', banners.patterns, 'app')
},
{
input: 'packages/app/src/photos.js',
plugins: [wqDeps(), babelAMD()],
external: ['localforage'],
output: outputAMD('photos', banners.photos, 'app')
},
{
input: 'packages/app/src/spinner.js',
plugins: [babelAMD()],
output: outputAMD('spinner', banners.spinner, 'app')
external: ['mustache'],
output: outputAMD('app', banner)
}
];
9 changes: 2 additions & 7 deletions packages/app/src/__tests__/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
*/

import app from '../app';
import patterns from '../patterns';
import photos from '../photos';
import router from '@wq/router';
import routeConfig from './config.json';
import templates from './templates.json';
import jqmrenderer from '@wq/jquery-mobile';
import jqmrenderer, { photos } from '@wq/jquery-mobile';
import { encode } from '@wq/outbox/vendor/json-forms';
import promiseFinally from 'promise.prototype.finally';

Expand All @@ -21,14 +19,12 @@ beforeAll(async () => {
router: {
base_url: '/tests'
},
template: {
templates
},
store: {
service: 'http://localhost:8080/tests',
defaults: { format: 'json' }
},
jqmrenderer: {
templates,
noScroll: true
},
backgroundSync: -1,
Expand All @@ -42,7 +38,6 @@ beforeAll(async () => {
};

app.use(jqmrenderer);
app.use(patterns);
app.use(photos);
app.use({
context(context, routeInfo) {
Expand Down
11 changes: 4 additions & 7 deletions packages/app/src/app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ds from '@wq/store';
import modelModule from '@wq/model';
import outbox from '@wq/outbox';
import tmpl from '@wq/template';
import router from '@wq/router';
import spinner from './spinner';
import Mustache from 'mustache';

var app = {
OFFLINE: 'offline',
Expand Down Expand Up @@ -139,9 +139,6 @@ app.init = function(config) {
outbox.app = app;
app.router = router;

// Initialize wq/template.js
tmpl.init(config.template);

// Option to submit forms in the background rather than wait for each post
if (config.backgroundSync) {
if (config.backgroundSync === -1) {
Expand Down Expand Up @@ -499,7 +496,7 @@ app.postsaveurl = function(item, alreadySynced) {
} else {
urlContext = { ...item.data, ...item.result };
}
url = app.base_url + '/' + tmpl.render(postsave, urlContext);
url = app.base_url + '/' + Mustache.render(postsave, urlContext);
} else if (!pconf.list) {
url = app.base_url + '/' + pconf.url;
} else {
Expand Down Expand Up @@ -1062,7 +1059,7 @@ app.submitForm = async function(kwargs) {
if (conf) {
options.modelConf = conf;
if (conf.label_template) {
options.label = tmpl.render(conf.label_template, vals);
options.label = Mustache.render(conf.label_template, vals);
}
}

Expand Down Expand Up @@ -1499,7 +1496,7 @@ function _computeFilter(filter, context) {
}
values = values.map(function(value) {
if (value && value.indexOf && value.indexOf('{{') > -1) {
value = tmpl.render(value, context);
value = Mustache.render(value, context);
if (value === '') {
return null;
} else if (value.match(/^\+\d+$/)) {
Expand Down
Loading

0 comments on commit 851fe0d

Please sign in to comment.