chore: init commit
in worker.../repo/GITFOLDER.zip is the .git folder.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
<%= form_with model: @user, scope: :user, url: @user.persisted? ? admin_user_path(@user) : admin_users_path, builder: Admin::FormBuilder, class: "space-y-6" do |f| %>
|
||||
<div class="bg-white shadow-sm ring-1 ring-gray-900/5 rounded-lg">
|
||||
<div class="px-6 py-6">
|
||||
<h3 class="text-lg font-medium text-gray-900 mb-6">User Details</h3>
|
||||
|
||||
<%= f.text_field :username,
|
||||
label: "Username",
|
||||
hint: "Unique username for the user",
|
||||
placeholder: "johndoe" %>
|
||||
|
||||
<%= f.select :type,
|
||||
options_for_select(
|
||||
%w[User Student Teacher].map { |t| [t, t] },
|
||||
@user.type
|
||||
),
|
||||
label: "User Type",
|
||||
hint: "Select the type of user (Student, Teacher, or generic User)",
|
||||
include_blank: false %>
|
||||
|
||||
<%= f.text_field :email,
|
||||
label: "Email",
|
||||
hint: "Email address (required for Teachers and Admins, optional for Students)",
|
||||
placeholder: "user@example.com" %>
|
||||
|
||||
<%= f.boolean_field :admin,
|
||||
label: "Admin",
|
||||
hint: "Grant admin privileges to this user" %>
|
||||
|
||||
<%= f.select :classroom_id,
|
||||
options_from_collection_for_select(
|
||||
Classroom.order(:name),
|
||||
:id,
|
||||
:name,
|
||||
@user.classroom_id
|
||||
),
|
||||
label: "Classroom",
|
||||
hint: "Optional classroom assignment",
|
||||
include_blank: "No classroom" %>
|
||||
|
||||
<% if @user.new_record? %>
|
||||
<div class="mt-6 pt-6 border-t border-gray-200">
|
||||
<h4 class="text-md font-medium text-gray-900 mb-4">Password</h4>
|
||||
|
||||
<%= f.password_field :password,
|
||||
label: "Password",
|
||||
hint: "Minimum 6 characters",
|
||||
placeholder: "••••••••" %>
|
||||
|
||||
<%= f.password_field :password_confirmation,
|
||||
label: "Password Confirmation",
|
||||
hint: "Re-enter password to confirm",
|
||||
placeholder: "••••••••" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-x-4">
|
||||
<%= f.cancel_button "Cancel", url: @user.persisted? ? admin_user_path(@user) : admin_users_path %>
|
||||
<%= f.submit_button @user.persisted? ? "Update User" : "Create User" %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -0,0 +1,10 @@
|
||||
<div class="max-w-7xl mx-auto">
|
||||
<%= admin_breadcrumbs(@breadcrumbs) %>
|
||||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold text-gray-900">Edit User</h1>
|
||||
<p class="text-gray-600 mt-2"><%= @user.username %></p>
|
||||
</div>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
@@ -0,0 +1,95 @@
|
||||
<div class="max-w-7xl mx-auto">
|
||||
<%= admin_breadcrumbs(@breadcrumbs) %>
|
||||
|
||||
<div class="bg-white shadow-sm ring-1 ring-gray-900/5 rounded-lg overflow-hidden">
|
||||
<div class="px-4 py-5 sm:px-6 border-b border-gray-200 flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-gray-900">Users</h3>
|
||||
<div class="flex gap-2">
|
||||
<%= link_to "New User", new_admin_user_path,
|
||||
class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-300">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
<%= sort_link(:id, "ID") %>
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
<%= sort_link(:username, "Username") %>
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
<%= sort_link(:type, "Type") %>
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
<%= sort_link(:email, "Email") %>
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
Classroom
|
||||
</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
||||
<%= sort_link(:admin, "Admin") %>
|
||||
</th>
|
||||
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-6">
|
||||
<span class="sr-only">Actions</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% if @users.any? %>
|
||||
<% @users.each do |user| %>
|
||||
<tr class="hover:bg-gray-50 transition-colors cursor-pointer"
|
||||
data-controller="clickable-row"
|
||||
data-clickable-row-url-value="<%= user_show_path(user) %>"
|
||||
data-action="click->clickable-row#navigate">
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<%= user.id %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<%= user.username %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<%= user.type %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<%= user.email.presence || content_tag(:span, "—", class: "text-gray-400") %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<%= user.classroom&.name || content_tag(:span, "—", class: "text-gray-400") %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900">
|
||||
<% if user.admin? %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">Yes</span>
|
||||
<% else %>
|
||||
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">No</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
|
||||
<div class="flex justify-end gap-2">
|
||||
<%= link_to "View", user_show_path(user), class: "text-blue-600 hover:text-blue-800" %>
|
||||
<%= link_to "Edit", edit_admin_user_path(user), class: "text-gray-600 hover:text-gray-800" %>
|
||||
<%= link_to "Delete", admin_user_path(user),
|
||||
data: { turbo_method: :delete, turbo_confirm: "Are you sure?" },
|
||||
class: "text-red-600 hover:text-red-800" %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<tr>
|
||||
<td colspan="7" class="px-3 py-12 text-center text-sm text-gray-500">
|
||||
<div class="flex flex-col items-center">
|
||||
<i class="fas fa-inbox text-4xl text-gray-300 mb-3"></i>
|
||||
<p class="font-medium">No records found</p>
|
||||
<p class="text-gray-400 mt-1">No users found. Create your first user to get started.</p>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="max-w-7xl mx-auto">
|
||||
<%= admin_breadcrumbs(@breadcrumbs) %>
|
||||
|
||||
<div class="mb-6">
|
||||
<h1 class="text-3xl font-bold text-gray-900">New User</h1>
|
||||
</div>
|
||||
|
||||
<%= render "form" %>
|
||||
</div>
|
||||
@@ -0,0 +1,51 @@
|
||||
<div class="max-w-7xl mx-auto">
|
||||
<%= admin_breadcrumbs(@breadcrumbs) %>
|
||||
|
||||
<div class="bg-white shadow-sm ring-1 ring-gray-900/5 rounded-lg mb-6">
|
||||
<div class="px-6 py-6">
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h2 class="text-2xl font-bold text-gray-900"><%= @user.username %></h2>
|
||||
<div class="flex gap-3">
|
||||
<%= link_to edit_admin_user_path(@user),
|
||||
class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50" do %>
|
||||
<i class="fas fa-edit -ml-1 mr-2 h-5 w-5 text-gray-500"></i>
|
||||
Edit
|
||||
<% end %>
|
||||
<%= link_to admin_user_path(@user),
|
||||
data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to delete this user?" },
|
||||
class: "inline-flex items-center px-4 py-2 border border-red-300 shadow-sm text-sm font-medium rounded-md text-red-700 bg-white hover:bg-red-50" do %>
|
||||
<i class="fas fa-trash -ml-1 mr-2 h-5 w-5 text-red-500"></i>
|
||||
Delete
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= admin_show_attributes(
|
||||
@user,
|
||||
attributes: %i[id username type email admin classroom created_at updated_at]
|
||||
) %>
|
||||
|
||||
<!-- Associated Portfolio -->
|
||||
<% if @user.portfolio.present? %>
|
||||
<div class="mt-6 pt-6 border-t border-gray-200">
|
||||
<h3 class="text-sm font-medium text-gray-500 mb-3">Portfolio</h3>
|
||||
<div class="text-sm text-gray-900">
|
||||
Portfolio ID: <%= @user.portfolio.id %>
|
||||
<% if @user.student? %>
|
||||
<%= link_to "View Portfolio", user_portfolio_path(@user, @user.portfolio), class: "ml-2 text-blue-600 hover:text-blue-800" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="mt-6 pt-6 border-t border-gray-200">
|
||||
<p class="text-sm text-gray-500">No portfolio associated with this user.</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<%= link_to "Back to Users", admin_users_path,
|
||||
class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50" %>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user