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

Fix for cards losing their values when in "dirty" state & adding back highlight - 7.5.x #10642

Merged
Show file tree
Hide file tree
Changes from 13 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
14 changes: 14 additions & 0 deletions arches/app/datatypes/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class URLDataType(BaseDataType):

def validate(self, value, row_number=None, source=None, node=None, nodeid=None, strict=False, **kwargs):
errors = []

if value is not None:
try:
if value.get("url") is not None:
Expand All @@ -82,6 +83,14 @@ def validate(self, value, row_number=None, source=None, node=None, nodeid=None,
title = _("Invalid HTTP/HTTPS URL")
error_message = self.create_error_message(value, source, row_number, message, title)
errors.append(error_message)

# raise error if label added without URL (#10592)
if value.get("url_label") and not value.get("url"):
message = _("URL label cannot be saved without a URL")
title = _("No URL added")
error_message = self.create_error_message(value, source, row_number, message, title)
errors.append(error_message)
jacobtylerwalls marked this conversation as resolved.
Show resolved Hide resolved

return errors

def transform_value_for_tile(self, value, **kwargs):
Expand Down Expand Up @@ -255,3 +264,8 @@ def default_es_mapping(self):
},
}
}

def pre_tile_save(self, tile, nodeid):
if tile.data[nodeid]:
if tile and "url_label" not in tile.data[nodeid]:
SDScandrettKint marked this conversation as resolved.
Show resolved Hide resolved
tile.data[nodeid]["url_label"] = ""
6 changes: 6 additions & 0 deletions arches/app/media/css/tree.scss
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@
margin-right: -2px;
}
}

.unsaved-edit {
background: #ffdb70;
color: #fff;
border-width: 2px;
}

a.tree-display-tool {
margin: 0px;
Expand Down
6 changes: 6 additions & 0 deletions arches/app/media/js/viewmodels/node-value-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ define([
initSelection: function(element, callback) {
var id = $(element).val();
var tiles = self.tiles();

// fixes #10027 where inputted values will be reset after navigating away
if (self.value()) {
id = self.value();
}

if (id !== "") {
var setSelection = function(tiles, callback) {
var selection = _.find(tiles, function(tile) {
Expand Down
4 changes: 4 additions & 0 deletions arches/app/media/js/views/components/widgets/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ define([

});

if (self.currentDefaultText() === "") {
self.defaultValue("");
Copy link
Contributor

Choose a reason for hiding this comment

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

@SDScandrettKint, @jacobtylerwalls - I was looking at this as it was causing me issues (of my own making) and in look at this I was wondering if line 184 should be:
self.defaultValue(initialDefault);
rather than setting the value to an empty string. I think (?) that the value and defaultValues should be the i18n object unless I've got that wrong... If my assumption is correct, not sure if this might bite us somewhere down the road...

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering along the same lines here, but I remember being less concerned about it when I saw other logic that watches the value and supplies the missing language keys (I think?)

This whole viewmodel is pretty involved, so I'm hoping we can kind of just make it to the Vue cutover without having to refactor it.

}

};

return ko.components.register('text-widget', {
Expand Down
10 changes: 10 additions & 0 deletions arches/app/media/js/views/components/widgets/urldatatype.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ define([

WidgetViewModel.apply(this, [params]);


// #10027 assign this.url & this.url_label with value versions for updating UI with edits
jacobtylerwalls marked this conversation as resolved.
Show resolved Hide resolved
if (ko.isObservable(this.value) && this.value()) {
var valueUrl = this.value().url;
var valueUrlLabel = this.value().url_label;
this.url(valueUrl);
this.url_label(valueUrlLabel);
}


this.urlPreviewText = ko.pureComputed(function() {
if (this.url()) {
if (this.url_label && this.url_label()) {
Expand Down
Loading