Skip to content

Commit

Permalink
URL datatype fixes for archesproject#8451, archesproject#10027 and ar…
Browse files Browse the repository at this point in the history
  • Loading branch information
SDScandrettKint committed Mar 1, 2024
1 parent ba59758 commit b1629f1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions arches/app/datatypes/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,27 @@ def validate(self, value, row_number=None, source=None, node=None, nodeid=None,
),
}
)

# raise error if label added without URL (#10592)
if value.get("url_label") and not value.get("url"):
errors.append(
{
"type": "ERROR",
"message": "datatype: {0} value: {1} {2} {3} - {4}. {5}".format(
self.datatype_model.datatype,
value,
source,
row_number,
"URL label cannot be saved without a URL",
"No URL added.",
),
}
)

if "url_label" not in value:
value["url_label"] = ""


return errors

def transform_value_for_tile(self, value, **kwargs):
Expand Down
11 changes: 11 additions & 0 deletions arches/app/media/js/views/components/widgets/urldatatype.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ define(['knockout', 'viewmodels/widget'], function(ko, WidgetViewModel) {
params.valueProperties = ['url', 'url_label'];
WidgetViewModel.apply(this, [params]);

// #10027 assign this.url & this.url_label with value versions for updating UI with edits
if (typeof (this.value) === "function") {
if (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

0 comments on commit b1629f1

Please sign in to comment.