create user on Portal, experimental

This commit is contained in:
Seven Du 2014-03-11 22:04:10 +08:00
parent c23e176a3f
commit f80404c777
2 changed files with 80 additions and 1 deletions

View File

@ -41,6 +41,17 @@ var App = Ember.Application.create({
}
});
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller) {
// alert("setupController");
},
actions: {
newUser: function() {
return Bootstrap.ModalManager.show('newUserForm');
}
}
});
App.CallsRoute = Ember.Route.extend({
setupController: function(controller) {
// Set the IndexController's `title`
@ -196,6 +207,17 @@ App.UsersRoute = Ember.Route.extend({
}
});
App.newUserRoute = Ember.Route.extend({
setupController: function(Controller) {
alert("auto_update_calls");
},
actions: {
show: function(controller) {
App.newUserController.show();
}
}
});
App.Router.map(function(){
this.route("calls");
this.route("channels");
@ -218,6 +240,7 @@ App.Router.map(function(){
this.route("showLimits");
this.route("show");
this.route("users");
this.route("newUser");
this.route("about", { path: "/about" });
});
@ -243,6 +266,14 @@ App.Channel = Em.Object.extend({
});
App.ApplicationController = Ember.ObjectController.extend({
actions: {
newUser: function() {
alert("ApplicationController");
}
}
});
App.callsController = Ember.ArrayController.create({
content: [],
init: function(){
@ -714,6 +745,39 @@ App.usersController = Ember.ArrayController.create({
}
});
App.UsersController = Ember.ObjectController.extend({
xnewUserButtons: [
{title: 'Submit', clicked: "submit"},
{title: 'Cancel', clicked: "cancel", dismiss: 'modal'}
],
actions: {
//Submit the modal
submit: function() {
$.post("/txtapi/lua?create_user.lua%20" + $("#user_id").val(), {
data: "user_id=xxxx",
success: function() { },
error: function(e) { }
});
// Bootstrap.NM.push('Successfully submitted modal', 'success');
return Bootstrap.ModalManager.hide('newUserForm');
},
//Cancel the modal, we don't need to hide the model manually because we set {..., dismiss: 'modal'} on the button meta data
cancel: function() {
Bootstrap.ModalManager.hide('newUserForm');
return Bootstrap.NM.push('Modal was cancelled', 'info');
},
//Show the modal
newUser: function() {
return Bootstrap.ModalManager.show('newUserForm');
}
}
});
// App.initialize();
var global_debug_event = false;
var global_background_job = false;

View File

@ -595,8 +595,23 @@
<br>
</script>
<script type="text/x-handlebars" data-template-name="users">
<script type="text/x-handlebars" data-template-name="users" id="users/index">
<div class="pull-right">
{{#bs-button type="primary" clicked="newUser"}}Create User{{/bs-button}}
</div>
{{#bs-modal name="newUserForm" fade="true" footerButtonsBinding="newUserButtons" title="Create User (Experimental)"}}
<p>
User ID: <input name="user_id" id="user_id"></input><br>
</p>
<div class="modal-footer">
{{#bs-button type="primary" clicked="submit"}}Create{{/bs-button}}
{{#bs-button clicked="cancel"}}Cancel{{/bs-button}}
</div>
{{/bs-modal}}
<h1>Users</h1>
<div>
<table class="table">
<tr>