Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactoring #167

Merged
merged 1 commit into from
Sep 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
'use strict'

// TODO

const {
ExecutedLint,
ExecutedTestCoverage,
ExecutedTestCoverageCheck,
ExecutedTestCoverageReport,
LoggedTotalCoverageByJsonSummary
ExecutedLint //,
// ExecutedTestCoverage,
// ExecutedTestCoverageCheck,
// ExecutedTestCoverageReport,
// LoggedTotalCoverageByJsonSummary
} = require('@cuties/wall')
const { ReadDataByPath } = require('@cuties/fs')
const { ParsedJSON } = require('@cuties/json')
const { SpawnedCommand } = require('@cuties/spawn')

new SpawnedCommand('grunt').after(
/* new SpawnedCommand('grunt').after(
new ExecutedLint(process, './src', './test').after(
new ExecutedTestCoverageReport(
new ExecutedTestCoverageCheck(
Expand All @@ -30,4 +32,8 @@ new SpawnedCommand('grunt').after(
)
)
)
).call() */

new SpawnedCommand('grunt').after(
new ExecutedLint(process, './src', './test')
).call()
2,302 changes: 658 additions & 1,644 deletions ehtml.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ehtml.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/backend/static/js/ehtml.bundle.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions examples/src/e-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@
id="form"
data-request-url="https://guseyn.com/echo"
data-request-button-id="#send"
data-upload-progress-bar-id="#progressBar"
data-upload-progress-bar-id="#uploadProgressBar"
data-progress-bar-id="#progressBar"
data-object="saved"
data-actions="
saveToMemoryStorage(saved, ${saved});
hideElms(#form);
innerHTML(#result, /../html/form-result.html);
applyValuesToChildNodes(#form-result, ${saved});
mapObjToElm(#form-result, ${saved});
addHTMLTo(#result-with-only-files, /../html/form-result-only-files.html);
applyValuesToChildNodes(#form-result-only-files, ${saved});
mapObjToElm(#form-result-only-files, ${saved});
showElms(#result, #result-with-only-files);
disableElms(#send);">

Expand Down Expand Up @@ -91,7 +92,8 @@

<button id="send">Send request</button>

<e-upload-progress-bar id="progressBar"></e-progress-bar>
<e-upload-progress-bar id="uploadProgressBar"></e-upload-progress-bar>
<e-progress-bar id="progressBar"></e-progress-bar>
</e-form>
<div id="result" style="display: none;"></div>
<div id="result-with-only-files" style="display: none;">
Expand Down
20 changes: 10 additions & 10 deletions examples/src/e-json.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<body class="main">
<e-json
id="block1"
data-src="/../user?id=1"
data-method="GET"
data-request-url="/../user?id=1"
data-request-method="GET"
data-object="user1"
data-actions="applyValuesToChildNodes(#block1, ${user1})">
data-actions="mapObjToElm(#block1, ${user1})">
<div style="border: 1px solid black; padding: 10px;">
<div data-text="First user info:"></div>
<div data-text="id: ${user1.id}"></div>
Expand All @@ -25,10 +25,10 @@
<br/>
<e-json
id="block2"
data-src="/../user?id=2"
data-method="GET"
data-request-url="/../user?id=2"
data-request-method="GET"
data-object="user2"
data-actions="applyValuesToChildNodes(#block2, ${user2})">
data-actions="mapObjToElm(#block2, ${user2})">
<div data-text="Second user info (in the first user info block):" style="border: 1px solid black; padding: 10px;">
<div data-text="id: ${user2.id}"></div>
<div data-text="name: ${user2.name}"></div>
Expand All @@ -48,11 +48,11 @@
</e-json>
<e-json
id="block3"
data-src="/../save_user"
data-method="POST"
data-object="savedUser"
data-request-url="/../save_user"
data-request-method="POST"
data-request-body='{"name": "newUser", "email": "newEmail@email.com"}'
data-actions="applyValuesToChildNodes(#block3, ${savedUser})">
data-object="savedUser"
data-actions="mapObjToElm(#block3, ${savedUser})">
<div style="border: 1px solid black; padding: 10px; margin-top: 10px">
<div data-text="We've just got new saved user:">
<div data-text="id: ${savedUser.id}"></div>
Expand Down
69 changes: 34 additions & 35 deletions out/new/EHTML.js → out/E.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,57 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

var _require = require('@page-libs/cutie'),
browserified = _require.browserified;
var StringWithAppliedStorageVariables = require('./util/StringWithAppliedStorageVariables');

var _browserified = browserified(require('@cuties/object')),
CreatedOptions = _browserified.CreatedOptions;

var _browserified2 = browserified(require('@cuties/json')),
ParsedJSON = _browserified2.ParsedJSON;

var _require2 = require('@page-libs/ajax'),
ResponseFromAjaxRequest = _require2.ResponseFromAjaxRequest,
ResponseBody = _require2.ResponseBody;

var _require3 = require('@page-libs/dom'),
UnwrappedChildrenOfParent = _require3.UnwrappedChildrenOfParent,
ElementWithInnerHTML = _require3.ElementWithInnerHTML;

var EElement = require('./EElement');

var EHTML =
var E =
/*#__PURE__*/
function (_HTMLElement) {
_inherits(EHTML, _HTMLElement);
_inherits(E, _HTMLElement);

function EHTML() {
function E() {
var _this;

_classCallCheck(this, EHTML);
_classCallCheck(this, E);

_this = _possibleConstructorReturn(this, _getPrototypeOf(EHTML).call(this));
_this.elm = new EElement(_assertThisInitialized(_this), ['data-src', 'data-headers'], []);
_this = _possibleConstructorReturn(this, _getPrototypeOf(E).call(this));
_this.rendered = false;
return _this;
}

_createClass(EHTML, [{
_createClass(E, [{
key: "onRender",
value: function onRender() {
throw new Error('render function must be overridden');
}
}, {
key: "attr",
value: function attr(name) {
return this.getAttribute(name);
}
}, {
key: "applyStorageValuesToAttributes",
value: function applyStorageValuesToAttributes() {
for (var i = 0; i < this.attributes.length; i++) {
this.setAttribute(this.attributes[i].name, new StringWithAppliedStorageVariables(this.attributes[i].value).value());
}
}
}, {
key: "connectedCallback",
value: function connectedCallback() {
var _this2 = this;

this.elm.connectedCallback(function () {
new UnwrappedChildrenOfParent(new ElementWithInnerHTML(_this2.elm, new ResponseBody(new ResponseFromAjaxRequest(new CreatedOptions('url', _this2.elm.attrValue('data-src'), 'method', 'GET', 'headers', new ParsedJSON(_this2.elm.attrValue('data-headers') || '{}')))))).after(_this2.elm.appliedActions()).call();
this.applyStorageValuesToAttributes();
setTimeout(function () {
if (!_this2.rendered) {
_this2.onRender();

_this2.rendered = true;
}
});
}
}], [{
key: "observedAttributes",
get: function get() {
return this.elm.observedAttributes;
}
}]);

return EHTML;
return E;
}(_wrapNativeSuper(HTMLElement));

window.customElements.define('e-html', EHTML);
module.exports = EHTML;
module.exports = E;
17 changes: 17 additions & 0 deletions out/async/AppliedActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var _require = require('@cuties/object'),
TheSameObjectWithValue = _require.TheSameObjectWithValue;

var Actions = require('./../util/Actions');

var AppliedActions = function AppliedActions(tagName, objName, actions, supportedActions, obj) {
_classCallCheck(this, AppliedActions);

var OBJ = {};
return new TheSameObjectWithValue(OBJ, objName, obj).after(new Actions(tagName, actions, supportedActions).asAsyncTree(OBJ));
};

module.exports = AppliedActions;
131 changes: 0 additions & 131 deletions out/async/ElementWithAppliedValuesToAttributesForChildNodes.js

This file was deleted.

Loading