Skip to content

Commit

Permalink
Metadata editor / recommended values for fields show an empty value. (g…
Browse files Browse the repository at this point in the history
…eonetwork#7232)

* Metadata editor / recommended values for fields show an empty value. Fixes geonetwork#7231

* Metadata editor / recommended values for fields show an empty value - fix radio mode

* Metadata editor / recommended values for fields - fix selected value in radio mode
  • Loading branch information
josegar74 authored Aug 29, 2023
1 parent 59c9b0e commit 3a33b6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@

// Load the config from the textarea containing the helpers
scope.config = angular.fromJson($("#" + scope.ref + "_config")[0].value);
if (scope.mode == "") {
scope.config.defaultSelected = {
"@value": "",
"#text": $translate.instant("recommendedValues"),
disabled: true
};
} else {
scope.config.defaultSelected = {};
}

// If only one option, convert to an array
if (!$.isArray(scope.config.option)) {
Expand All @@ -146,6 +155,11 @@
scope.config.option = scope.config;
}

if (scope.mode == "") {
// Add on top the recommended values option
scope.config.option.unshift(scope.config.defaultSelected);
}

// Add record formats if any
scope.isProtocol =
attrs.tooltip.indexOf && attrs.tooltip.indexOf("protocol|") !== -1;
Expand Down Expand Up @@ -180,7 +194,8 @@
}

// Set the initial value
scope.config.selected = {};
scope.config.selected = scope.config.defaultSelected;

scope.config.value =
field.type === "number" ? parseFloat(field.value) : field.value;
scope.config.layout =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
type="radio"
data-ng-click="select(o)"
name="ignore_{{ref}}"
data-ng-checked="o['@value'] === config.value"
data-ng-checked="o['@value'] == config.value"
/>
{{o['#text']}}
</label>
Expand Down Expand Up @@ -70,9 +70,7 @@
class="form-control"
data-ng-model="config.selected"
data-ng-options="o as o['#text'] disable when o.disabled for o in config.option"
>
<option value="" disabled="" data-translate="">recommendedValues</option>
</select>
></select>
</div>
</div>
</span>

0 comments on commit 3a33b6e

Please sign in to comment.