-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use searchable select for user invitation form
Load users quota state via ajax.
- Loading branch information
Showing
7 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
jQuery(function($) { | ||
$('.admin_users form.pageflow_invitation_form').each(function() { | ||
var quotaStates = $('.quota_state', this); | ||
var quotaStateContainer = $('#quota_state_container', this); | ||
var accountSelect = $('#invitation_form_membership_entity_id', this); | ||
var fieldsets = $('#invitation_form_details', this).add('fieldset.actions', this); | ||
|
||
function filterQuotaStatesBySelectedAccount() { | ||
function updateQutaState() { | ||
var selectedAccountId = accountSelect.val(); | ||
|
||
quotaStates.each(function(){ | ||
var quotaState = $(this); | ||
var accountId = quotaState.data('accountId').toString(); | ||
$.get('/admin/users/quota_state?account_id=' + selectedAccountId) | ||
.success(function(html) { | ||
quotaStateContainer.html(html); | ||
updateForm(); | ||
}); | ||
} | ||
|
||
if (accountId !== selectedAccountId) { | ||
$(quotaState).hide(); | ||
} | ||
else { | ||
$(quotaState).show(); | ||
function updateForm() { | ||
if (quotaAvailable()) { | ||
fieldsets.show(); | ||
} | ||
else { | ||
fieldsets.hide(); | ||
} | ||
} | ||
|
||
if ($(quotaState).data('state') === 'available') { | ||
fieldsets.show(); | ||
} | ||
else { | ||
fieldsets.hide(); | ||
} | ||
} | ||
}); | ||
function quotaAvailable() { | ||
return !!quotaStateContainer.find('[data-state=available]').length; | ||
} | ||
|
||
filterQuotaStatesBySelectedAccount(); | ||
accountSelect.on('change', filterQuotaStatesBySelectedAccount); | ||
accountSelect.on('change', updateQutaState); | ||
updateForm(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= users_quota_state(@account) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters