<div class="row reg-field-row" ng-show="show_field('au.home_ou')">
[% draw_field_label('au', 'home_ou') %]
<div class="col-md-3 reg-field-input">
- <eg-org-selector selected="patron.home_ou" onchange="handle_home_org_changed">
+ <eg-org-selector
+ selected="patron.home_ou"
+ onchange="handle_home_org_changed"
+ disable-test="disable_home_org">
</eg-org-selector>
</div>
</div>
[% draw_field_label('aua', 'address_type') %]
[% draw_form_input('aua', 'address_type', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'address_type') %]
+ [% draw_example_text('aua', 'address_type') %]
</div>
</div>
[% draw_field_label('aua', 'post_code') %]
[% draw_form_input('aua', 'post_code', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'post_code') %]
+ [% draw_example_text('aua', 'post_code') %]
</div>
</div>
[% draw_field_label('aua', 'street1') %]
[% draw_form_input('aua', 'street1', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'street1') %]
+ [% draw_example_text('aua', 'street1') %]
</div>
</div>
[% draw_field_label('aua', 'street2') %]
[% draw_form_input('aua', 'street2', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'street2') %]
+ [% draw_example_text('aua', 'street2') %]
</div>
</div>
[% draw_field_label('aua', 'city') %]
[% draw_form_input('aua', 'city', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'city') %]
+ [% draw_example_text('aua', 'city') %]
</div>
</div>
[% draw_field_label('aua', 'county') %]
[% draw_form_input('aua', 'county', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'county') %]
+ [% draw_example_text('aua', 'county') %]
</div>
</div>
[% draw_field_label('aua', 'state') %]
[% draw_form_input('aua', 'state', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'state') %]
+ [% draw_example_text('aua', 'state') %]
</div>
</div>
[% draw_field_label('aua', 'country') %]
[% draw_form_input('aua', 'country', 'addresses[$index]') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'country') %]
+ [% draw_example_text('aua', 'country') %]
</div>
</div>
[% draw_field_label('aua', 'valid') %]
[% draw_form_input('aua', 'valid', 'addresses[$index]', 'checkbox') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'valid') %]
+ [% draw_example_text('aua', 'valid') %]
</div>
</div>
[% draw_field_label('aua', 'within_city_limits') %]
[% draw_form_input('aua', 'within_city_limits', 'addresses[$index]', 'checkbox') %]
<div class="col-md-6 patron-reg-example">
- [% draw_example_text('au', 'within_city_limits') %]
+ [% draw_example_text('aua', 'within_city_limits') %]
</div>
</div>
.then(function(p) { return p.indexOf(org_id) > -1; });
}
+ service.has_user_edit_perms = function(org_id) {
+ return egCore.perm.hasPermAt('CREATE_USER', true)
+ .then(function(p) { return p.indexOf(org_id) > -1; });
+ }
+
service.get_surveys = function() {
var org_ids = egCore.org.fullPath(egCore.auth.user().ws_ou(), true);
_is_mailing : true,
_is_billing : true,
within_city_limits : false,
- stat_cat_entries : []
+ country : service.org_settings['ui.patron.default_country'],
};
var card = {
card : card,
cards : [card],
home_ou : egCore.org.get(egCore.auth.user().ws_ou()),
+ stat_cat_entries : [],
addresses : [addr]
};
addr.isnew = true;
addr.valid = true;
addr.within_city_limits = true;
+ addr.country($scope.org_settings['ui.patron.default_country']);
$scope.patron.addresses.push(addr);
}
patronRegSvc.invalidate_field($scope.patron, field);
}
+
$scope.dupe_value_changed = function(type, value) {
$scope.dupe_counts[type] = 0;
patronRegSvc.dupe_patron_search($scope.patron, type, value)
// TODO: check edit perms
$scope.handle_home_org_changed = function() {
org_id = $scope.patron.home_ou.id();
+
patronRegSvc.has_group_link_perms(org_id)
.then(function(bool) {$scope.has_group_link_perm = bool});
+
+ patronRegSvc.has_user_edit_perms(org_id)
+ .then(function(bool) {$scope.has_user_edit_perm = bool});
}
// This is called with every character typed in a form field,
break;
case 'dob':
- // TODO: very date is valid; update juvenile.
+ maintain_juvenile_flag();
break;
}
$scope.field_modified();
}
+ // patron.juvenile is set to true if the user was born after
+ function maintain_juvenile_flag() {
+ if ( !($scope.patron && $scope.patron.dob) ) return;
+
+ var juv_interval =
+ $scope.org_settings['global.juvenile_age_threshold']
+ || '18 years';
+
+ var base = new Date();
+
+ base.setTime(base.getTime() -
+ Number(egCore.date.intervalToSeconds(juv_interval) + '000'));
+
+ $scope.patron.juvenile = ($scope.patron.dob > base);
+ }
+
+ // returns true (disable) for orgs that cannot have users.
+ $scope.disable_home_org = function(org_id) {
+ if (!org_id) return;
+ var org = egCore.org.get(org_id);
+ return (
+ org &&
+ org.ou_type() &&
+ org.ou_type().can_have_users() == 'f'
+ );
+ }
+
/* NOTE: this function is not necessary since angular applies
* the needed classes as each field becomes valid/invalid.
* Leaving it here for now for reference.
return $('#patron-reg-container.ng-invalid').length > 0;
}
+ $scope.edit_passthru.hide_save_actions = function() {
+ return (
+ !$scope.has_user_edit_perm ||
+ $scope.edit_passthru.has_invalid_fields()
+ );
+ }
+
$scope.edit_passthru.save = function(save_args) {
if (!save_args) save_args = {};