add new files
This commit is contained in:
130
app/views/users/_form.html.erb
Normal file
130
app/views/users/_form.html.erb
Normal file
@@ -0,0 +1,130 @@
|
||||
|
||||
<%= simple_form_for(@user) do |f| %>
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="<%= users_path %>">User</a>
|
||||
<a class="breadcrumb-item active" href="#">
|
||||
<% if !@user.id.nil? %>
|
||||
Edit
|
||||
<% else %>
|
||||
New
|
||||
<% end %>
|
||||
</a>
|
||||
</nav>
|
||||
<div class="content">
|
||||
<% if @user.id.nil? %>
|
||||
<div class="row">
|
||||
<div class="col-md-5" >
|
||||
<div class="form-group">
|
||||
<label for="email" class="string optional control-label">Registered Email:</label>
|
||||
<input type="text" id="registered_email" name="registered_email" class="form-control" placeholder="Please enter member mail">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<label for="email" class="string optional control-label"> </label>
|
||||
<button type="button" class="btn btn-primary" style="float:right;" id="check_email" >Check</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-md-6" id="textbox_group">
|
||||
<div class ="form-group" >
|
||||
<label for="name" class="string optional control-label">Name:</label>
|
||||
<%= f.input :name ,:label =>false,:error => false,:placeholder =>'Please enter user name',input_html: { class: "form-control" } %>
|
||||
<%= f.error :name ,style: 'color: red' %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="nrc" class="string optional control-label">NRC:</label>
|
||||
<%= f.input :nrc ,:error=>false,:label =>false,:placeholder =>'Please enter user NRC',input_html: { class: "form-control" } %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="email" class="string optional control-label">Email:</label>
|
||||
<%= f.input :email ,:error=>false,:label =>false ,:placeholder =>'Please enter user email',input_html: { class: "form-control" } %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="phone" class="string optional control-label">Phone:</label>
|
||||
<%= f.input :phone,:error=>false,:label =>false,:placeholder =>'Please enter user phone',input_html: { class: "form-control" } %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="address" class="string optional control-label">Address:</label>
|
||||
<%= f.input :address,:error=>false,:label =>false,:placeholder =>'Please enter user address',input_html: { class: "form-control" } %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="secret_key" class="string optional control-label">Secrect Key:</label>
|
||||
<%= f.input :secrect_key,:error=>false,:label =>false,:placeholder =>'Please enter user secret key',input_html: { class: "form-control" } %>
|
||||
</div>
|
||||
<% if !@user.id.nil? %>
|
||||
<div class ="form-group" >
|
||||
<label for="is_active" class="string optional control-label">Active:</label>
|
||||
<%= f.check_box :is_active %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class ="form-group" >
|
||||
<label></label>
|
||||
<div class="actions">
|
||||
<%= f.button :submit, :class => 'btn btn-primary',:id =>'btn_submit' %>
|
||||
<%= link_to 'Cancel', users_path ,:class => 'btn btn-primary',:id => 'btnback' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<script >
|
||||
$(document).ready(function() {
|
||||
status='disabled'
|
||||
name=$("#user_name").val()
|
||||
if (name.trim() !=""){
|
||||
status=''
|
||||
}
|
||||
enable_control(status)
|
||||
|
||||
$("#check_email").click(function(){
|
||||
registered_email = $("#registered_email").val();
|
||||
$.ajax({
|
||||
type:'get',
|
||||
url: '<%= check_registered_email_path %>',
|
||||
data:'registered_email='+ registered_email ,
|
||||
success:function(result){
|
||||
// $("#show-data").html('')
|
||||
if (result.status == 'true'){
|
||||
enable_control(false)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.data === null){
|
||||
enable_control(true)
|
||||
}
|
||||
else
|
||||
{
|
||||
$(result.data).each(function(i){
|
||||
name = result.data.name
|
||||
nrc =result.data.nrc
|
||||
phone =result.data.phone
|
||||
address =result.data.address
|
||||
email = result.data.email
|
||||
|
||||
$("#user_name").val(name)
|
||||
$("#user_email").val(email)
|
||||
$("#user_nrc").val(nrc)
|
||||
$("#user_phone").val(email)
|
||||
$("#user_address").val(address)
|
||||
$("#btn_submit").hide()
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
function enable_control(status){
|
||||
$("#user_name").prop('disabled',status);
|
||||
$("#user_email").prop('disabled',status);
|
||||
$("#user_nrc").prop('disabled',status);
|
||||
$("#user_phone").prop('disabled',status);
|
||||
$("#user_address").prop('disabled',status);
|
||||
$("#btn_submit").prop('disabled',status)
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
2
app/views/users/_user.json.jbuilder
Normal file
2
app/views/users/_user.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! user, :id, :created_at, :updated_at
|
||||
json.url user_url(user, format: :json)
|
||||
1
app/views/users/edit.html.erb
Normal file
1
app/views/users/edit.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render 'form' %>
|
||||
54
app/views/users/index.html.erb
Normal file
54
app/views/users/index.html.erb
Normal file
@@ -0,0 +1,54 @@
|
||||
<div class="row ">
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item active" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="#">Users</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row top-content">
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_user_path,:class => 'btn btn-primary' %>
|
||||
</span>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<strong>User List</strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Nrc</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Address</th>
|
||||
<th>Status</th>
|
||||
<th>Created At </th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name rescue '' %></td>
|
||||
<td><%= user.nrc rescue '' %></td>
|
||||
<td><%= user.email rescue '' %></td>
|
||||
<td><%= user.phone rescue '' %></td>
|
||||
<td><%= user.address rescue '' %></td>
|
||||
<td><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td>
|
||||
<%= link_to 'Detail',
|
||||
user_path(user), :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
||||
edit_user_path(user), :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to 'Delete', user_path(user), method: :delete, data: { confirm: 'Are you sure?' },:class => 'btn btn-primary btn-sm' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%=paginate @users %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/users/index.json.jbuilder
Normal file
1
app/views/users/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @users, partial: 'users/user', as: :user
|
||||
1
app/views/users/new.html.erb
Normal file
1
app/views/users/new.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render 'form' %>
|
||||
51
app/views/users/show.html.erb
Normal file
51
app/views/users/show.html.erb
Normal file
@@ -0,0 +1,51 @@
|
||||
<div class="row">
|
||||
<nav class="breadcrumb">
|
||||
<a class="breadcrumb-item" href="<%= dashboard_path %>">Home</a>
|
||||
<a class="breadcrumb-item active" href="<%= users_path %>">Users</a>
|
||||
<a class="breadcrumb-item active" href="#">Show</a>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="col-lg-6 show">
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>Name:</strong></div>
|
||||
<div class="col-lg-8 uppercase"><%= @user.name %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>NRC:</strong></div>
|
||||
<div class="col-lg-8"><%= @user.nrc %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>Email:</strong></div>
|
||||
<div class="col-lg-8"><%= @user.email %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>Phone:</strong></div>
|
||||
<div class="col-lg-8"><%= @user.phone %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>Address:</strong></div>
|
||||
<div class="col-lg-8"><%= @user.address %></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-4"><strong>Active:</strong></div>
|
||||
<div class="col-lg-8">
|
||||
|
||||
<% if @user.is_active %>
|
||||
<input type="checkbox" checked disabled="true" />
|
||||
<% else %>
|
||||
<input type="checkbox" disabled="true"/>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="col-lg-3"></div>
|
||||
<div class="col-lg-4 btn-show-action">
|
||||
<%= link_to 'Edit', edit_user_path(@user),:class => 'btn btn-primary' %>
|
||||
<%= link_to 'Back', users_path ,:class => 'btn btn-primary'%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
1
app/views/users/show.json.jbuilder
Normal file
1
app/views/users/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "users/user", user: @user
|
||||
Reference in New Issue
Block a user