From ec271a1445bf232cd172c38e2dd3fd9d3c5c7c4e Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 24 Apr 2015 22:19:34 -0500 Subject: RT#34289: Flag service fields as mandatory --- httemplate/browse/part_svc.cgi | 13 +++++++++++-- httemplate/edit/elements/part_svc_column.html | 15 ++++++++++++--- httemplate/edit/part_svc.cgi | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 5 deletions(-) (limited to 'httemplate') diff --git a/httemplate/browse/part_svc.cgi b/httemplate/browse/part_svc.cgi index 0d3685355..ec5f321dd 100755 --- a/httemplate/browse/part_svc.cgi +++ b/httemplate/browse/part_svc.cgi @@ -61,6 +61,8 @@ function part_export_areyousure(href) { Modifier + Required + % my $conf = FS::Conf->new; % foreach my $part_svc ( @part_svc ) { @@ -78,6 +80,9 @@ function part_export_areyousure(href) { % $col->columnflag || ( $col->columnlabel !~ /^\S*$/ % && $col->columnlabel ne $def->{'label'} % ) +% || ( $col->required +% && !$def->{'required'} +% ) % ) % } % @dfields ; @@ -150,7 +155,7 @@ function part_export_areyousure(href) { % unless ( @fields ) { -% for ( 1..4 ) { +% for ( 1..5 ) { % } % } @@ -170,7 +175,6 @@ function part_export_areyousure(href) { <% $field %> <% $label %> <% $flag{$flag} %> - % my $value = &$formatter($part_svc->part_svc_column($field)->columnvalue); % if ( $flag =~ /^[MAH]$/ ) { @@ -189,6 +193,11 @@ function part_export_areyousure(href) { % } + +% if ($part_svc_column->required) { + Yes +% } + % $n1=""; % } #foreach $field % if ( $part_svc->restrict_edit_password ) { diff --git a/httemplate/edit/elements/part_svc_column.html b/httemplate/edit/elements/part_svc_column.html index 2bb4f5e41..a6ccaf867 100644 --- a/httemplate/edit/elements/part_svc_column.html +++ b/httemplate/edit/elements/part_svc_column.html @@ -77,6 +77,7 @@ that field. Field Label Modifier + Required? % $part_svc->set('svcpart' => $opt{'clone'}) if $opt{'clone'}; # for now % my $i = 0; @@ -208,11 +209,19 @@ that field. 'empty_label' => "Select $mode class", 'multiple' => $multiple, &> +% } + + +% if (!$def->{'type'} || !(grep {$_ eq $def->{'type'}} ('checkbox','disabled'))) { + required || $def->{'required'}) ? 'CHECKED' : '' %> + <% $def->{'required'} ? 'DISABLED' : '' %> + > % } - + % if ( $def->{def_info} ) { (<% $def->{def_info} %>) @@ -228,7 +237,7 @@ that field. <% emt('Require "Provision" access right to edit password') %> - + restrict_edit_password ? 'CHECKED' : '' %>> @@ -244,7 +253,7 @@ that field. <% emt('This service has an attached router') %> - + has_router ? 'CHECKED' : '' %>> diff --git a/httemplate/edit/part_svc.cgi b/httemplate/edit/part_svc.cgi index 47b020c5a..7a47f1550 100755 --- a/httemplate/edit/part_svc.cgi +++ b/httemplate/edit/part_svc.cgi @@ -101,6 +101,15 @@ function flag_changed(obj) { } } } + var required = document.getElementById(layer + '__' + field + '_required'); + if (required && !required.disabledinit) { + if (newflag == "F") { + required.checked = false; + required.disabled = true; + } else { + required.disabled = false; + } + } } window.onload = function() { @@ -111,6 +120,17 @@ window.onload = function() { obj.setAttribute('should_be_multiple', true); } } + var inputs = document.getElementsByTagName('INPUT'); + for(i = 0; i < inputs.length; i++) { + var obj = inputs[i]; + if (obj.type == 'checkbox') { + if ( obj.name.match(/_required$/) ) { + if ( obj.disabled ) { + obj.disabledinit = 1; + } + } + } + } for(i = 0; i < selects.length; i++) { var obj = selects[i]; if ( obj.name.match(/_flag$/) ) { -- cgit v1.2.1