Skip to content

Commit

Permalink
conf: readonly references cannot be removed automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Feb 18, 2019
1 parent b4e8c88 commit afa3b4f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
7 changes: 5 additions & 2 deletions plugins/plugins-available/conf/lib/Monitoring/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ sub clone_refs {
if($incoming) {
for my $type (keys %{$incoming}) {
for my $name (keys %{$incoming->{$type}}) {
my $ref_id = $incoming->{$type}->{$name};
my $ref_id = $incoming->{$type}->{$name}->{'id'};
my $ref = $self->get_object_by_id($ref_id);
if(!$test_mode && $ref->{'file'}->{'readonly'}) {
next;
Expand Down Expand Up @@ -1285,7 +1285,10 @@ sub gather_references {
$incoming->{$type} = {};
for my $id (keys %{$refs->{$type}}) {
my $obj = $self->get_object_by_id($id);
$incoming->{$type}->{$obj->get_name()} = $id;
$incoming->{$type}->{$obj->get_name()} = {
id => $id,
readonly => $obj->{'file'}->readonly(),
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<ul class="obj_ref">
[% FOREACH t = incoming.keys.sort %]
[% FOREACH name = incoming.$t.keys.sort %]
[% oid = incoming.$t.$name %]
<li><a href="conf.cgi?sub=objects&amp;data.id=[% oid %]">[% name %]</a><span class="obj_ref">([% t %])</span></li>
[% inc_ref = incoming.$t.$name %]
<li><a href="conf.cgi?sub=objects&amp;data.id=[% inc_ref.id %]">[% name %]</a><span class="obj_ref">([% t %])</span></li>
[% END %]
[% END %]
</ul>
Expand Down
13 changes: 7 additions & 6 deletions plugins/plugins-available/conf/templates/conf_objects_listref.tt
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
<td class='dataVal'>
<ul [% IF force_delete %]style="padding-left: 15px;"[% END %]>
[% FOREACH name = incoming.$t.keys.sort %]
[% oid = incoming.$t.$name %]
[% inc_ref = incoming.$t.$name %]
[% IF force_delete %]
<li style="list-style: none;">
<input type="checkbox" name="ref" value="[% oid %]" checked>
<input type="checkbox" name="ref" value="[% inc_ref.id %]" [% IF inc_ref.readonly %]disabled[% ELSE %]checked[% END %]>
<a href="#" onclick="jQuery(this).prev().click(); jQuery('input[name=none]').prop('checked', false); return false;">[% name %]</a>
<a href="conf.cgi?sub=objects&amp;data.id=[% oid %]"><img src="[% url_prefix %]themes/[% theme %]/images/link.png" style="vertical-align: middle;"></a>
<a href="conf.cgi?sub=objects&amp;data.id=[% inc_ref.id %]"><img src="[% url_prefix %]themes/[% theme %]/images/link.png" style="vertical-align: middle;"></a>
[% IF inc_ref.readonly %] <span style="color: #EB6900"> (read-only)</span>[% END %]
</li>
[% ELSE %]
<li><a href="conf.cgi?sub=objects&amp;data.id=[% oid %]">[% name %]</a></li>
<li><a href="conf.cgi?sub=objects&amp;data.id=[% inc_ref.id %]">[% name %]</a></li>
[% END %]
[% END %]
</ul>
Expand All @@ -51,9 +52,9 @@
<td class='dataVal'>
select
<input type="checkbox" name="none" value="">
<a href="#" onclick="jQuery('input[name=ref]').prop('checked', false); jQuery('input[name=none]').prop('checked', true); jQuery('input[name=all]').prop('checked', false); return false;">none</a> -
<a href="#" onclick="jQuery('input[name=ref]').not(':disabled').prop('checked', false); jQuery('input[name=none]').prop('checked', true); jQuery('input[name=all]').prop('checked', false); return false;">none</a> -
<input type="checkbox" name="all" value="" checked>
<a href="#" onclick="jQuery('input[name=ref]').prop('checked', true); jQuery('input[name=none]').prop('checked', false); jQuery('input[name=all]').prop('checked', true); return false;">all</a>
<a href="#" onclick="jQuery('input[name=ref]').not(':disabled').prop('checked', true); jQuery('input[name=none]').prop('checked', false); jQuery('input[name=all]').prop('checked', true); return false;">all</a>
</td>
</tr>
[% END %]
Expand Down

0 comments on commit afa3b4f

Please sign in to comment.