Skip to content

Commit

Permalink
Refactor Router & Nav Components (breaking)
Browse files Browse the repository at this point in the history
  • Loading branch information
sentivate committed Feb 3, 2022
1 parent e49f0aa commit 8860322
Show file tree
Hide file tree
Showing 117 changed files with 3,568 additions and 2,911 deletions.
85 changes: 26 additions & 59 deletions uwBridge/apps/client/example!/filesystem/asset/Sentivate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
assignDeep,
ensureArray: ensureArray$1,
assign: assign$5,
each: each$9,
each: each$8,
isArray: isArray$1,
isEmpty,
sortNewest,
Expand Down Expand Up @@ -244,7 +244,7 @@
assignDeep(oldVal, newValArg);
} else {
const newVal = ensureArray$1(newValArg);
each$9(newVal, (item) => {
each$8(newVal, (item) => {
const oldValItem = findItem(oldVal, item[indexName], indexName);
if (hasValue(oldValItem)) {
assign$5(oldValItem, item);
Expand Down Expand Up @@ -289,7 +289,7 @@
watch: watch$2,
demand: demand$3,
utility: {
each: each$8, isFunction: isFunction$1
each: each$7, isFunction: isFunction$1
},
crate
} = app;
Expand All @@ -310,7 +310,7 @@
if (isFunction$1(componentName)) {
componentName(html);
} else {
each$8(app.view.findAllComponents(componentName), (item) => {
each$7(app.view.findAllComponents(componentName), (item) => {
if (app.debug) {
console.log(item);
}
Expand All @@ -330,15 +330,15 @@
watch$2.html = watchHtml;
const {
utility: {
each: each$7
each: each$6
}
} = app;
const importPartials = (componentName, componentModel, asset) => {
if (asset.partials) {
each$7(asset.partials, (item, key) => {
each$6(asset.partials, (item, key) => {
watchHtml(item.includes('.html') ? item : `${item}.html`, (html) => {
const realName = getComponentName(componentModel, componentName);
each$7(app.view.findAllComponents(realName), (subItem) => {
each$6(app.view.findAllComponents(realName), (subItem) => {
subItem.resetPartial(key, html);
});
});
Expand All @@ -364,7 +364,7 @@
};
const {
utility: {
each: each$6, isString: isString$3, isArray, apply: apply$2
each: each$5, isString: isString$3, isArray, apply: apply$2
}
} = app;
const logMulti = console;
Expand All @@ -385,15 +385,15 @@
}
if (events) {
if (isString$3(events)) {
each$6(events.split(','), (subItem) => {
each$5(events.split(','), (subItem) => {
if (subItem) {
currentView.fire(subItem.trim(), componentEvent, ...args);
}
});
} else if (isArray(events)) {
each$6(events, (item) => {
each$5(events, (item) => {
if (item) {
each$6(item.split(','), (subItem) => {
each$5(item.split(','), (subItem) => {
if (subItem) {
currentView.fire(subItem.trim(), componentEvent, ...args);
}
Expand All @@ -405,7 +405,7 @@
};
const {
utility: {
each: each$5, assign: assign$4, querySelector: querySelector$1
each: each$4, assign: assign$4, querySelector: querySelector$1
}
} = app;
const headNode = querySelector$1('head');
Expand Down Expand Up @@ -435,20 +435,20 @@
};
const cssRender = (css) => {
if (css) {
each$5(css, render);
each$4(css, render);
}
};
const cssUnrender = (css) => {
if (css) {
each$5(css, unrender);
each$4(css, unrender);
}
};
const componentsWithCss = {};
const registerCssComponent = (css, componentConfig) => {
if (!css) {
return;
}
each$5(css, (item, key) => {
each$4(css, (item, key) => {
if (!componentsWithCss[key]) {
componentsWithCss[key] = [];
}
Expand All @@ -463,7 +463,7 @@
const {
watch: watch$1,
utility: {
each: each$4, get, apply: apply$1
each: each$3, get, apply: apply$1
}
} = app;
const createWatchers = (currentView, item, key) => {
Expand Down Expand Up @@ -509,15 +509,15 @@
};
const removeInstance = function(currentView, css) {
cssUnrender(css);
each$4(currentView.watchers, (item, key) => {
each$3(currentView.watchers, (item, key) => {
item.stop();
item[key] = null;
});
};
const onrenderInstance = function(currentView, css) {
cssRender(css);
if (currentView.watchers) {
each$4(currentView.watchers, (item) => {
each$3(currentView.watchers, (item) => {
item.start();
});
}
Expand All @@ -529,7 +529,7 @@
const thisComponent = this;
thisComponent.watchers = watchers ? watchers(thisComponent) : {};
if (thisComponent.watchers) {
each$4(thisComponent.watchers, (item, key) => {
each$3(thisComponent.watchers, (item, key) => {
createWatchers(thisComponent, item, key);
});
}
Expand Down Expand Up @@ -609,7 +609,7 @@
demandCss,
demandHtml,
utility: {
assign: assign$2, each: each$3, ensureArray, isString: isString$2
assign: assign$2, each: each$2, ensureArray, isString: isString$2
}
} = app;
const asyncComponent = async function(componentConfig) {
Expand Down Expand Up @@ -637,7 +637,7 @@
if (asset.css) {
const assetCss = asset.css;
const loadCss = await demandCss(assetCss);
each$3(ensureArray(loadCss), (item, index) => {
each$2(ensureArray(loadCss), (item, index) => {
let keyName = assetCss[index];
if (!keyName.includes('.css')) {
keyName = `${keyName}.css`;
Expand Down Expand Up @@ -684,7 +684,7 @@
demand: demand$1,
watch,
utility: {
each: each$2, querySelector, isDom
each: each$1, querySelector, isDom
}
} = app;
const onCss = async (json) => {
Expand All @@ -699,7 +699,7 @@
node.innerHTML = content;
}
if (componentsUsingCss) {
each$2(componentsUsingCss, (item) => {
each$1(componentsUsingCss, (item) => {
console.log(item);
item.css[filePath] = content;
});
Expand All @@ -710,7 +710,7 @@
const {
demand,
utility: {
assign: assign$1, each: each$1, isFunction
assign: assign$1, each, isFunction
}
} = app;
const view = new Ractive({
Expand All @@ -728,7 +728,7 @@
const afterDemand = componentEvent.get('afterDemand');
if (afterDemand) {
const afterDemandEvents = afterDemand[componentEvent.original.type];
each$1(afterDemandEvents, (item, key) => {
each(afterDemandEvents, (item, key) => {
if (isFunction(item)) {
item(imported, item, key);
} else {
Expand Down Expand Up @@ -784,44 +784,11 @@
demandJs,
demandLang,
utility: {
cnsl, assign, each, map, isString, rest, camelCase, omit, last, batch, eventAdd, apply
cnsl, assign, mapArray, map, isString, rest, camelCase, omit, last, batch, eventAdd, apply, isRegExp, mapWhile
}
} = app;
const router = {};
const hostname = window.location.hostname;
router.historyIndex = 0;
const logRouter = console;
function debugRouter(...args) {
if (app.debug || app.debugRouter) {
apply(logRouter.log, logRouter, args);
}
}
Ractive.sharedSet('historyIndex', router.historyIndex);
cnsl('ROUTER ONLINE', 'important');
assign(router, {
add(item) {
each(item, router.addObject);
},
addObject(item, key) {
const reg = new RegExp(key);
router.routes.push(async () => {
return router.routeChecker(item, reg);
});
},
attachEvents() {
eventAdd(
window,
'popstate',
async (eventArg) => {
debugRouter('popstate', eventArg);
router.saveState();
router.updateLocation();
await router.loadState();
eventArg.preventDefault();
},
true
);
},
async closeState(previousStateObject) {
debugRouter('closeState', previousStateObject);
if (previousStateObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ul>
</div>
<div class="uk-navbar-center uk-navbar-item uk-logo">
<a class="uk-navbar-item uk-logo" on-click="routerLoad" href="/"><img width="40" src="{{@shared.logo.image}}">{{@shared.logo.title}}</a>
<a class="uk-navbar-item uk-logo" on-click="route" href="/"><img width="40" src="{{@shared.logo.image}}">{{@shared.logo.title}}</a>
</div>
<div class="uk-navbar-right">
<ul class="uk-navbar-nav">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
cnsl('page Module', 'notify');
exports.page = function(pageModule) {
let templateUrl;
const language = pageModule.assets.language;
const config = assignDeep({
data: {},
partials: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

</div>
{{#batch.feed}}
<div data-href="/batch/{{_id}}" on-click="routerLoad"
<div data-href="/batch/{{_id}}" on-click="route"
class="uk-border-rounded uk-overflow-hidden pointer uk-grid-match uk-card
uk-box-shadow-small uk-card-default uk-text-center uk-grid-collapse uk-card-row" uk-grid>

Expand All @@ -49,7 +49,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="">
<btn class="uk-width-1-1 round-right" type="primary" href="/codes/{{_id}}" click="routerLoad" title="View" />
<btn class="uk-width-1-1 round-right" type="primary" href="/codes/{{_id}}" click="route" title="View" />
</div>
</div>
</div>
Expand All @@ -65,7 +65,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="uk-text-center uk-child-width-1-1 " click="batch.create.load" >
<a class="uk-icon-link uk-padding-small" href="/codes/{{_id}}" on-click="routerLoad" uk-icon="fa-eye"></a>
<a class="uk-icon-link uk-padding-small" href="/codes/{{_id}}" on-click="route" uk-icon="fa-eye"></a>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ <h1 class="uk-heading-line uk-text-center uk-margin-remove-top uk-margin-remove-
</span>
</h1>
<div class="uk-width-expand uk-width-1-1">
<a href="/codes/{{batch.current._id}}" on-click="routerLoad">
<a href="/codes/{{batch.current._id}}" on-click="route">
<span class="uk-label">CODES: {{batch.current.codeCount}}</span>
</a>
<a href="/scans/batch/{{batch.current._id}}" on-click="routerLoad">
<a href="/scans/batch/{{batch.current._id}}" on-click="route">
<span class="uk-label">SCANS: {{batch.current.scanCount}}</span>
</a>
<a href="/feedback/batch/{{batch.current._id}}" on-click="routerLoad">
<a href="/feedback/batch/{{batch.current._id}}" on-click="route">
<span class="uk-label">FEEDBACK: {{batch.current.feedbackCount}}</span>
</a>
</div>
Expand Down Expand Up @@ -147,7 +147,7 @@ <h5 class="uk-margin-remove">Batch Questions</h5>
{{/}}
<h1 class="uk-heading-line uk-text-center uk-margin-remove-top uk-margin-remove-bottom">
<span>
<a href="/facility/{{batch.current.facility}}" on-click="routerLoad">
<a href="/facility/{{batch.current.facility}}" on-click="route">
{{batch.current.facilityData.name}}
</a>
</span>
Expand Down Expand Up @@ -190,7 +190,7 @@ <h5 class="uk-margin-remove">Facility Questions</h5>
{{/}}
<h1 class="uk-heading-line uk-text-center uk-margin-remove-top uk-margin-remove-bottom">
<span>
<a href="/organization/{{batch.current.organization}}" on-click="routerLoad">
<a href="/organization/{{batch.current.organization}}" on-click="route">
{{batch.current.organizationData.name}}
</a>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

</div>
{{#campaign.feed}}
<div data-href="/campaign/{{_id}}" on-click="routerLoad"
<div data-href="/campaign/{{_id}}" on-click="route"
class="uk-border-rounded uk-overflow-hidden pointer uk-grid-match uk-card
uk-box-shadow-small uk-card-default uk-text-center uk-grid-column-collapse uk-card-row" uk-grid>

Expand All @@ -49,7 +49,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="uk-text-center uk-child-width-1-1 " click="batch.create.load" >
<a href="#" class="uk-icon-link uk-padding-small" href="/feeback/{{_id}}" on-click="routerLoad" uk-icon="fa-eye"></a>
<a href="#" class="uk-icon-link uk-padding-small" href="/feeback/{{_id}}" on-click="route" uk-icon="fa-eye"></a>
</div>
</div>
</div>
Expand All @@ -65,7 +65,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="">
<btn class="uk-width-1-1 round-right" type="primary" href="/feeback/{{_id}}" click="routerLoad" title="View" />
<btn class="uk-width-1-1 round-right" type="primary" href="/feeback/{{_id}}" click="route" title="View" />
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

</div>
{{#code.feed}}
<div data-href="/code/{{_id}}" on-click="routerLoad"
<div data-href="/code/{{_id}}" on-click="route"
class="uk-border-rounded uk-overflow-hidden pointer uk-grid-match uk-card
uk-box-shadow-small uk-card-default uk-text-center uk-grid-collapse uk-card-row" uk-grid>

Expand All @@ -49,7 +49,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="">
<btn class="uk-width-1-1 round-right" type="primary" href="/feedback/{{_id}}" click="routerLoad" title="View" />
<btn class="uk-width-1-1 round-right" type="primary" href="/feedback/{{_id}}" click="route" title="View" />
</div>
</div>
</div>
Expand All @@ -65,7 +65,7 @@
</div>
<div class="uk-child-width-1-1 uk-grid-collapse" uk-grid>
<div class="uk-text-center uk-child-width-1-1">
<a class="uk-icon-link uk-padding-small" href="/feedback/{{_id}}" on-click="routerLoad" uk-icon="fa-eye"></a>
<a class="uk-icon-link uk-padding-small" href="/feedback/{{_id}}" on-click="route" uk-icon="fa-eye"></a>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 8860322

Please sign in to comment.