Skip to content

Commit b99139e

Browse files
authored
Merge pull request #239 from michaelkaesdorf/fix-display-idp-detail
fix(Admin.UI): fix display of idp properties
2 parents 79e9659 + 740a247 commit b99139e

File tree

3 files changed

+43
-37
lines changed

3 files changed

+43
-37
lines changed

src/Skoruba.Duende.IdentityServer.Admin.UI/Areas/AdminUI/Views/IdentityProvider/IdentityProvider.cshtml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@
9595
</div>
9696
<div class="row">
9797
<div class="col" id="property-list">
98+
@foreach (var property in Model.Properties)
99+
{
100+
<div class="property row mt-1 mb-1">
101+
<div class="col-sm">
102+
<input type="text" required value="@property.Value.Name" class="form-control" id="[email protected]" name="Properties[@property.Key].Name" />
103+
<span class="text-danger field-validation-error" data-valmsg-for="Properties[@property.Key].Name" data-valmsg-replace="true"></span>
104+
</div>
105+
<div class="col-sm">
106+
<input type="text" required value="@property.Value.Value" class="form-control" id="[email protected]" name="Properties[@property.Key].Value" />
107+
<span class="text-danger field-validation-error" data-valmsg-for="Properties[@property.Key].Value" data-valmsg-replace="true"></span>
108+
</div>
109+
<div class="col-sm-1 col-xs-1">
110+
<span class="remove-property oi oi-trash btn btn-danger"></span>
111+
</div>
112+
</div>
113+
}
98114
</div>
99115
</div>
100116
<div class="row">
@@ -123,8 +139,8 @@
123139
</form>
124140

125141
@section scripts
126-
{
127-
<script>
128-
IdentityProviders.init(@Model.Properties.Count, @Html.Raw(Json.Serialize(Model.Properties)));
129-
</script>
142+
{
143+
<script>
144+
IdentityProviders.init();
145+
</script>
130146
}
Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
11
var IdentityProviders = {
2-
3-
propertyCount: 0,
4-
properties: null,
5-
6-
init: function (propertyCount, properties) {
7-
8-
IdentityProviders.propertyCount = propertyCount;
9-
IdentityProviders.properties = properties;
10-
11-
IdentityProviders.loadProperties();
2+
init: function () {
123
IdentityProviders.eventHandlers();
134
},
145

15-
loadProperties: function () {
16-
Object.keys(IdentityProviders.properties).forEach(function (key) {
17-
$("#property-list").append(IdentityProviders.propertyTemplate(key, IdentityProviders.properties[key].name, IdentityProviders.properties[key].value));
18-
});
19-
},
20-
216
eventHandlers: function () {
22-
237
FormMvc.disableEnter($('#identity-provider-form'));
248

259
$("body").on("click", ".add-property", function (e) {
2610
e.preventDefault();
27-
var currentPropertyCount = IdentityProviders.propertyCount;
2811

29-
$("#property-list").append(IdentityProviders.propertyTemplate(currentPropertyCount, "", ""));
30-
IdentityProviders.propertyCount++;
12+
// Determine the current property index based on the number of existing properties
13+
var currentPropertyCount = $("#property-list .property").length;
14+
15+
// Append new property input fields using the updated count
16+
var resultingProperty = IdentityProviders.propertyTemplate(currentPropertyCount);
17+
18+
$("#property-list").append(resultingProperty);
19+
3120
});
3221

3322
$("body").on("click", ".remove-property", function (e) {
@@ -36,18 +25,19 @@
3625
});
3726
},
3827

39-
propertyTemplate: function (propertyIndex, key, value) {
40-
return '<div class="property row mt-1 mb-1">' +
41-
' <div class="col-sm">' +
42-
' <input type="text" required value="' + key + '" class="form-control" id="Properties_' + propertyIndex + '__Name" name="Properties[' + propertyIndex + '].Name" />' +
43-
' <span class="text-danger field-validation-error" data-valmsg-for="Properties[' + propertyIndex + '].Name" data-valmsg-replace="true"></span>' +
44-
' </div>' +
45-
' <div class="col-sm">' +
46-
' <input type="text" required value="' + value + '" class="form-control" id="Properties_' + propertyIndex + '__Value" name="Properties[' + propertyIndex + '].Value" />' +
47-
' <span class="text-danger field-validation-error" data-valmsg-for="Properties[' + propertyIndex + '].Value" data-valmsg-replace="true"></span>' +
48-
' </div>' +
49-
' <div class="col-sm-1 col-xs-1"><span class="remove-property oi oi-trash btn btn-danger"></span></div>' +
28+
propertyTemplate: function (propertyIndex) {
29+
return '<div class="property row mt-1 mb-1">'+
30+
'<div class="col-sm">'+
31+
'<input type="text" required value="" class="form-control" id="Properties_'+propertyIndex+'__Name" name="Properties['+propertyIndex+'].Name" />'+
32+
'<span class="text-danger field-validation-error" data-valmsg-for="Properties['+propertyIndex+'.Name" data-valmsg-replace="true"></span>'+
33+
'</div>'+
34+
'<div class="col-sm">'+
35+
'<input type="text" required value="" class="form-control" id="Properties_'+propertyIndex+'__Value" name="Properties['+propertyIndex+'].Value" />'+
36+
'<span class="text-danger field-validation-error" data-valmsg-for="Properties['+propertyIndex+'.Value" data-valmsg-replace="true"></span>'+
37+
'</div>'+
38+
'<div class="col-sm-1 col-xs-1">'+
39+
'<span class="remove-property oi oi-trash btn btn-danger"></span>'+
40+
'</div>'+
5041
'</div>';
5142
}
52-
5343
};

src/Skoruba.Duende.IdentityServer.Admin.UI/wwwroot/dist/js/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)