Skip to content

Commit 500d385

Browse files
committed
Add links to help map statuses that have the same name
1 parent 3679823 commit 500d385

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

share/html/Admin/Lifecycles/Mappings.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@
6464
% my $ToMapping = $LifecycleObj->MoveMap($Other);
6565
% my @OtherStatuses = $Other->Valid;
6666

67-
<&| /Widgets/TitleBox, title => $Other->Name &>
67+
% require List::MoreUtils;
68+
<&| /Widgets/TitleBox, title => $Other->Name,
69+
List::MoreUtils::duplicates( map { lc } @MyStatuses, @OtherStatuses )
70+
? ( titleright_raw => '<a href="#" class="lifecycle-auto-map">' . loc('Map same names if unset') . '</a>' )
71+
: (),
72+
&>
6873
<div class="form-row">
6974
<div class="col-6">
7075
<h6 class="text-center my-3"><&|/l, $Other->Name, $LifecycleObj->Name &>From [_1] to [_2]</&></h6>
@@ -104,6 +109,28 @@ <h6 class="text-center my-3"><&|/l, $LifecycleObj->Name, $Other->Name &>From [_1
104109
</div>
105110

106111
</form>
112+
113+
<script type="text/javascript">
114+
jQuery('.lifecycle-auto-map').click(function() {
115+
jQuery(this).closest('div.titlebox').find('select').each(function() {
116+
const select = jQuery(this);
117+
if ( select.val() ) {
118+
return;
119+
}
120+
else {
121+
const from = select.attr('name').replace(/map-.*--(.*)--.*/, '$1').toLowerCase();
122+
select.find('option').each(function() {
123+
if ( jQuery(this).attr('value').toLowerCase() === from ) {
124+
select.val(jQuery(this).attr('value'));
125+
select.selectpicker('refresh');
126+
return false;
127+
}
128+
});
129+
}
130+
});
131+
return false;
132+
});
133+
</script>
107134
% }
108135
<%INIT>
109136
my ($title, @results);

0 commit comments

Comments
 (0)