mirror of https://github.com/pixelfed/pixelfed
Add Curated Onboarding Templates
parent
795e91e3bc
commit
071163b47b
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CuratedRegisterTemplate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name', 'description', 'content', 'is_active', 'order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('curated_register_templates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('content')->nullable();
|
||||
$table->boolean('is_active')->default(false)->index();
|
||||
$table->tinyInteger('order')->default(10)->unsigned()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('curated_register_templates');
|
||||
}
|
||||
};
|
@ -0,0 +1,98 @@
|
||||
@extends('admin.partial.template-full')
|
||||
|
||||
@section('section')
|
||||
</div><div class="header bg-primary pb-3 mt-n4">
|
||||
<div class="container-fluid">
|
||||
<div class="header-body">
|
||||
<div class="row align-items-center py-4">
|
||||
<div class="col-lg-8 col-12">
|
||||
<p class="display-1 text-white d-inline-block mb-0">Curated Onboarding</p>
|
||||
<p class="text-white mb-0">The ideal solution for communities seeking a balance between open registration and invite-only membership</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if((bool) config_cache('instance.curated_registration.enabled'))
|
||||
<div class="m-n2 m-lg-4">
|
||||
<div class="container-fluid mt-4">
|
||||
@include('admin.curated-register.partials.nav')
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="display-4">Create Template</h2>
|
||||
<p class="lead my-0">Create re-usable templates of messages and application requests.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<p class="font-weight-bold mb-0">{{ $error }}</p>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
<form method="post">
|
||||
@csrf
|
||||
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Shortcut/Name</label>
|
||||
<input
|
||||
class="form-control"
|
||||
name="name"
|
||||
value="{{old('name')}}"
|
||||
placeholder="An optional name/shortcut for easy access" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Content</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
name="content"
|
||||
value="{{old('content')}}"
|
||||
rows="8"
|
||||
placeholder="Add your custom message template here..."></textarea>
|
||||
</div>
|
||||
|
||||
<p class="font-weight-bold">
|
||||
<a class="font-weight-bold small" data-toggle="collapse" href="#collapseDescription" aria-expanded="false" aria-controls="collapseDescription">
|
||||
Add optional description
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<div class="collapse" id="collapseDescription">
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Description</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
name="description"
|
||||
rows="4"
|
||||
placeholder="Add an optional description that is only visible to admins..."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="active" name="active" checked>
|
||||
<label class="custom-control-label font-weight-bold" for="active">Mark as Active</label>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<button class="btn btn-primary btn-block rounded-pill font-weight-bold">Create Template</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endsection
|
@ -0,0 +1,148 @@
|
||||
@extends('admin.partial.template-full')
|
||||
|
||||
@section('section')
|
||||
</div><div class="header bg-primary pb-3 mt-n4">
|
||||
<div class="container-fluid">
|
||||
<div class="header-body">
|
||||
<div class="row align-items-center py-4">
|
||||
<div class="col-lg-8 col-12">
|
||||
<p class="display-1 text-white d-inline-block mb-0">Curated Onboarding</p>
|
||||
<p class="text-white mb-0">The ideal solution for communities seeking a balance between open registration and invite-only membership</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if((bool) config_cache('instance.curated_registration.enabled'))
|
||||
<div class="m-n2 m-lg-4">
|
||||
<div class="container-fluid mt-4">
|
||||
@include('admin.curated-register.partials.nav')
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-lg-8">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success font-weight-bold lead" id="shm">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(() => document.getElementById('shm').classList.add('animate__animated', 'animate__bounceOutLeft'), 2000);
|
||||
setTimeout(() => document.getElementById('shm').style.display = 'none', 2500);
|
||||
</script>
|
||||
@endif
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h2 class="display-4 mb-0">Edit Template</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger">
|
||||
@foreach ($errors->all() as $error)
|
||||
<p class="font-weight-bold mb-0">{{ $error }}</p>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
<form method="post" id="updateForm">
|
||||
@csrf
|
||||
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Shortcut/Name</label>
|
||||
<input
|
||||
class="form-control"
|
||||
name="name"
|
||||
value="{{$template->name}}"
|
||||
placeholder="An optional name/shortcut for easy access" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Content</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
name="content"
|
||||
rows="{{$template->content && strlen($template->content) > 500 ? 16 : 5}}"
|
||||
placeholder="Add your custom message template here...">{{$template->content}}</textarea>
|
||||
</div>
|
||||
|
||||
@if($template->description == null)
|
||||
<p class="font-weight-bold">
|
||||
<a class="font-weight-bold small" data-toggle="collapse" href="#collapseDescription" aria-expanded="false" aria-controls="collapseDescription">
|
||||
Add optional description
|
||||
</a>
|
||||
</p>
|
||||
@endif
|
||||
|
||||
<div class="collapse {{ $template->description === null ? '':'show'}}" id="collapseDescription">
|
||||
<div class="form-group">
|
||||
<label class="small font-weight-bold">Description</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
name="description"
|
||||
rows="4"
|
||||
placeholder="Add an optional description that is only visible to admins...">{{ $template->description }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="active" name="active" {{ $template->is_active ? 'checked' : ''}}>
|
||||
<label class="custom-control-label font-weight-bold" for="active">Mark as Active</label>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="d-flex">
|
||||
<button type="button" class="btn btn-primary flex-grow-1 rounded-pill font-weight-bold" id="saveBtn">Save</button>
|
||||
<button type="button" class="btn btn-danger rounded-pill font-weight-bold" id="deleteBtn">Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" id="deleteForm">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$('#saveBtn').click(() => {
|
||||
$('#updateForm').submit()
|
||||
})
|
||||
$('#deleteBtn').click(() => {
|
||||
swal({
|
||||
title: 'Confirm Deletion',
|
||||
text: 'Are you sure you want to delete this template? It will not be recoverable',
|
||||
icon: 'warning',
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
close: {
|
||||
text: "Close",
|
||||
value: "close",
|
||||
close: true,
|
||||
className: "swal-button--cancel"
|
||||
},
|
||||
confirm: {
|
||||
text: "Delete",
|
||||
value: "delete",
|
||||
className: "btn-danger"
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
if(res == 'delete') {
|
||||
$('#deleteForm').submit();
|
||||
// window.location.href = '/i/admin/curated-onboarding/templates';
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
@ -0,0 +1,91 @@
|
||||
@extends('admin.partial.template-full')
|
||||
|
||||
@section('section')
|
||||
</div><div class="header bg-primary pb-3 mt-n4">
|
||||
<div class="container-fluid">
|
||||
<div class="header-body">
|
||||
<div class="row align-items-center py-4">
|
||||
<div class="col-lg-8 col-12">
|
||||
<p class="display-1 text-white d-inline-block mb-0">Curated Onboarding</p>
|
||||
<p class="text-white mb-0">The ideal solution for communities seeking a balance between open registration and invite-only membership</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if((bool) config_cache('instance.curated_registration.enabled'))
|
||||
<div class="m-n2 m-lg-4">
|
||||
<div class="container-fluid mt-4">
|
||||
@include('admin.curated-register.partials.nav')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@if (session('status'))
|
||||
<div class="alert alert-success font-weight-bold lead" id="shm">
|
||||
{{ session('status') }}
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(() => document.getElementById('shm').classList.add('animate__animated', 'animate__bounceOutLeft'), 2000);
|
||||
setTimeout(() => document.getElementById('shm').style.display = 'none', 2500);
|
||||
</script>
|
||||
@endif
|
||||
<div class="card">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<p class="lead my-0">Create and manage re-usable templates of messages and application requests.</p>
|
||||
<a class="btn btn-primary font-weight-bold rounded-pill" href="{{route('admin.curated-onboarding.create-template')}}">Create new Template</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12">
|
||||
|
||||
<div class="table-responsive rounded">
|
||||
<table class="table table-dark">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Shortcut/Name</th>
|
||||
<th scope="col">Content</th>
|
||||
<th scope="col">Active</th>
|
||||
<th scope="col">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($templates as $template)
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<a
|
||||
href="/i/admin/curated-onboarding/templates/edit/{{$template->id}}"
|
||||
class="font-weight-bold">
|
||||
{{ $template->id }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $template->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ str_limit($template->content, 80) }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $template->is_active ? '✅' : '❌' }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $template->created_at->format('M d Y') }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="d-flex mt-3">
|
||||
{{ $templates->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endsection
|
Loading…
Reference in New Issue