This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 279
fix: improve handling of merging defaults for popup tiles #519
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
311c9d4
move popup defaults to constants.js
akloeckner f47a0b8
use -item-transparent explicitly for camera, fix cursor/actions
akloeckner 1f0c000
Merge branch 'master' into feature/defaults
akloeckner 5bece8b
use new feature `action: false`
akloeckner 52dfdab
fix classes option to always only ADD classes when merging configurat…
akloeckner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like
angular.merge
will merge those array values:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think https://www.npmjs.com/package/lodash.merge should work.
angular.merge
is deprecated anyway and they recommendlodash.merge
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question for this line might be: What is actually expected?
angular.merge
will merge bykey
, which is1,2,3,...
in the case of arrays. So, values in the same place will be overwritten, values in other places will be added. Since both use cases should be possible, I'd say this behavior is reasonable to expect.Here's a more complete test case:
If we wanted only add user-defined classes, we could do so like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of classes, I think the default behavior should be to append user classes to the ones that are there already because then the user doesn't need the knowledge of internal classes to add something. The
[ , ...]
also requires knowledge of how many internal classes are already applied and is error-prone in case something changes internally in the future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant, we could use the
[, ...]
inmain.js
. The users should definitely not need to to this themselves.If we were to use another library, I'll need help to include it in the bundle. Just a hint: The merge of arrays will need to use the current (angular) behavior in a few prominent places, e.g., the main tile in popups (i.e. camera, iframe, history)...
In summary, I suggest to change the
classes
line(s) inmain.js
in the[, ...]
way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An additional thought on that is: we have two kinds of places where we would want to merge tile configurations
a) before "evaluation" of functions and templates, prominent example is during config loading.
b) after "evaluation" of functions and templates, prominent example might be the popups.
The a) case could be solved by nesting functions:
Question is: Which
item
is meant in each of the functions? During config loading it will easy, because it can only be the sameitem
. In the case of popups, it's not that easy. The function in the default will probably want to use theitem
in the popup. The function in the callingitem
will probably want to use that callingitem
.So, I'm under the impression, it might boild down to the point: when do we actually want to evaluate functions and templates?
(Sorry for turning into a philosopher. :-) Maybe I should wait for you to be less ocupied...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated akloeckner/TileBoard@feature/defaults...akloeckner:test/merge-tiles in a way that I believe should handle all cases well.
(It's untested, so treat it as a sketch.)classes
will always be concatenated.this.parseFieleValue
on both properties to be mergeditem
alwaysitem
.Possible downsides:
parseFieldValue
ed. But that should be ok, because non-parseable properties are simply piped through.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't mean to leave you here talking to yourself but I don't have much capacity for it currently.
I guess go ahead with your plan and I'll likely approve after a brief look :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. I prefer to put down my notes, so you could pick up the line of thought. I'll give it another round of thinking and then go ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this approach to the PR. Would you mind a quick look? ;-)