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

71 extend event #75

Closed
wants to merge 9 commits into from
Closed

71 extend event #75

wants to merge 9 commits into from

Conversation

cubap
Copy link
Member

@cubap cubap commented Aug 10, 2020

addresses #74
Still has some unhandled errors when unexpanded renders start, but it does eventually render as expected.

Draft for now, since the edges are still ragged and this will be a big pull, but feel free to comment @thehabes in case this doesn't address your cases.

@cubap cubap added the enhancement New feature or request label Aug 10, 2020
@cubap cubap requested a review from thehabes August 10, 2020 18:02
@cubap cubap self-assigned this Aug 10, 2020
@@ -414,7 +414,7 @@ <h4>Simple Forms</h4>
</footer>


<script src="./releases/alpha-.10/deer.js" type="module"></script>
<script src="./js/deer.js" type="module"></script>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put this back before merging. This should be our most recent release and the text version needs to change too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we did a fresh release and i was wondering if you wanted to up the version. We should do that today.

@@ -55,6 +55,9 @@ async function renderChange(mutationsList) {

export default class DeerReport {
constructor(elem, deer = {}) {

return false

for (let key in DEER) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obviously some trimming here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo this is scary.

RENDER.detectInsertions = elem => {
let newViews = (elem.querySelectorAll(config.VIEW).length) ? elem.querySelectorAll(config.VIEW) : []
let newForms = (elem.querySelectorAll(config.FORM).length) ? elem.querySelectorAll(config.VIEW) : []
if (newForms.length) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length might be more than is needed here, I forget why it was done.

UTILS.worker.addEventListener("message", event => {
let templ = DEER.TEMPLATES[elem.getAttribute(DEER.TEMPLATE) || (elem.getAttribute(DEER.COLLECTION) ? "list" : "json")]
if (event.data.action === "expanded") {
RENDER.applyTemplate(elem, event.data.item, templ)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe pass options in here so we aren't checking twice

js/deer-utils.js Outdated
@@ -105,6 +115,23 @@ export default {
return label || noLabel
}
},
postView(entity, matchOn = ["__rerum.generatedBy", "creator"]){
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the model for form handling and other messages sent into the worker as well.

@@ -105,6 +115,23 @@ export default {
return label || noLabel
}
},
postView(entity, matchOn = ["__rerum.generatedBy", "creator"]){
let UTILS = this
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point I was having trouble with the scope of this. Setting it at the top of the function strong-arms the scope to UTILS so that the key word this isn't conflated in loops and what not. It may not be necessary any more, but if you plan to undo it for this make sure to test it and put breakpoints around the uses of this so you can be sure it is what you expect.

if (typeof findId !== "string") {
return Promise.resolve(entity)
}
return fetch(findId).then(response => response.json())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unchanged, just lifted from expand()

* @param {String} id URI for the targeted entity
* @param [String] targetStyle other formats of resource targeting. May be null
*/
async function findByTargetId(id, targetStyle = [],queryUrl="http://tinydev.rerum.io/app/query") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

straight copy

* @param Object fromAnno parent annotation of the asserted value, as a handy metadata container.
* @returns Object with `value` and `source` keys.
*/
function buildValueObject(val, fromAnno) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp

return valueObject
}

function getValue(property, alsoPeek = [], asType) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cp

@@ -55,6 +55,9 @@ async function renderChange(mutationsList) {

export default class DeerReport {
constructor(elem, deer = {}) {

return false

for (let key in DEER) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo this is scary.

@@ -105,6 +115,23 @@ export default {
return label || noLabel
}
},
postView(entity, matchOn = ["__rerum.generatedBy", "creator"]){
let UTILS = this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point I was having trouble with the scope of this. Setting it at the top of the function strong-arms the scope to UTILS so that the key word this isn't conflated in loops and what not. It may not be necessary any more, but if you plan to undo it for this make sure to test it and put breakpoints around the uses of this so you can be sure it is what you expect.

@@ -0,0 +1,162 @@
const filesToCache = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super fun

cubap added 2 commits August 12, 2020 12:51
next commit moves into correct function
try {
let inputElems = this.inputs
let flatKeys = inputElems.map(input => input.getAttribute(DEER.KEY))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into utils.js

@cubap cubap closed this Aug 18, 2022
@cubap cubap deleted the 71-extend-event branch August 24, 2022 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants