DataInventory
Changes
app/Controllers/Http/OrganizationTypeController.js 121(+121 -0)
app/Models/OrganizationType.js 9(+9 -0)
resources/views/inc/nav.edge 3(+3 -0)
start/routes.js 3(+2 -1)
Details
app/Controllers/Http/OrganizationTypeController.js 121(+121 -0)
diff --git a/app/Controllers/Http/OrganizationTypeController.js b/app/Controllers/Http/OrganizationTypeController.js
new file mode 100644
index 0000000..c44b6f5
--- /dev/null
+++ b/app/Controllers/Http/OrganizationTypeController.js
@@ -0,0 +1,121 @@
+'use strict'
+
+/** @typedef {import('@adonisjs/framework/src/Request')} Request */
+/** @typedef {import('@adonisjs/framework/src/Response')} Response */
+/** @typedef {import('@adonisjs/framework/src/View')} View */
+const OrganizationType = use('App/Models/OrganizationType')
+const { validate } = use('Validator')
+
+/**
+ * Resourceful controller for interacting with organizationtypes
+ */
+class OrganizationTypeController {
+ /**
+ * Show a list of all organizationtypes.
+ * GET organizationtypes
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ * @param {View} ctx.view
+ */
+ async index ({ request, response, view }) {
+ const types = await OrganizationType.all()
+
+ return view.render('organization_types.index', {
+ types: types.toJSON()
+ })
+ }
+
+ /**
+ * Render a form to be used for creating a new organizationtype.
+ * GET organizationtypes/create
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ * @param {View} ctx.view
+ */
+ async create ({ request, response, view }) {
+ return view.render('organization_types.create')
+ }
+
+ /**
+ * Create/save a new organizationtype.
+ * POST organizationtypes
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ */
+ async store ({ request, response }) {
+ const data = request.only(['type'])
+
+ const validation = await validate(request.all(), {
+ type: 'required',
+ }, {
+ 'type.required': `Organization type is required`,
+ })
+
+ if(validation.fails()) {
+ session.withErrors(validation.messages()).flashAll()
+ return response.redirect('back')
+ }
+
+ await OrganizationType.create(data)
+
+ return response.redirect('/organization_types')
+ }
+
+ /**
+ * Display a single organizationtype.
+ * GET organizationtypes/:id
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ * @param {View} ctx.view
+ */
+ async show ({ params, request, response, view }) {
+ }
+
+ /**
+ * Render a form to update an existing organizationtype.
+ * GET organizationtypes/:id/edit
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ * @param {View} ctx.view
+ */
+ async edit ({ params, request, response, view }) {
+ }
+
+ /**
+ * Update organizationtype details.
+ * PUT or PATCH organizationtypes/:id
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ */
+ async update ({ params, request, response }) {
+ }
+
+ /**
+ * Delete a organizationtype with id.
+ * DELETE organizationtypes/:id
+ *
+ * @param {object} ctx
+ * @param {Request} ctx.request
+ * @param {Response} ctx.response
+ */
+ async destroy ({ params, request, response }) {
+ const type = await OrganizationType.findOrFail(params.id)
+ await type.delete()
+
+ return response.redirect('/organization_types')
+ }
+}
+
+module.exports = OrganizationTypeController
app/Models/OrganizationType.js 9(+9 -0)
diff --git a/app/Models/OrganizationType.js b/app/Models/OrganizationType.js
new file mode 100644
index 0000000..2ccae77
--- /dev/null
+++ b/app/Models/OrganizationType.js
@@ -0,0 +1,9 @@
+'use strict'
+
+/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
+const Model = use('Model')
+
+class OrganizationType extends Model {
+}
+
+module.exports = OrganizationType
resources/views/inc/nav.edge 3(+3 -0)
diff --git a/resources/views/inc/nav.edge b/resources/views/inc/nav.edge
index 132ab28..908f96f 100644
--- a/resources/views/inc/nav.edge
+++ b/resources/views/inc/nav.edge
@@ -20,6 +20,9 @@
<li>
<a href="{{ route('/organizations.index') }}">Organizations</a>
</li>
+ <li>
+ <a href="{{ route('/organization_types.index') }}">Organization Types</a>
+ </li>
</ul>
</section>
diff --git a/resources/views/organization_types/create.edge b/resources/views/organization_types/create.edge
new file mode 100644
index 0000000..1b1a804
--- /dev/null
+++ b/resources/views/organization_types/create.edge
@@ -0,0 +1,29 @@
+@layout('layouts.main')
+
+@section('content')
+
+<form method="POST" action="{{ route('/organization_types.store') }}">
+ {{ csrfField() }}
+ <div class="field">
+ <label class="label">Organization Type</label>
+ <input class="input" type="text" name="type" placeholder="Admin boundaries" value="{{ old('type', '') }}" />
+ {{ elIf('<span class="has-text-danger">$self</span>', getErrorFor('type'), hasErrorFor('type')) }}
+ </div>
+
+ <div class="field is-grouped">
+ <div class="control">
+ <button class="button is-link ss-submit" type="submit">Submit</button>
+ </div>
+ <div class="control">
+ <button class="button is-text"><a href="{{ route('/organization_types.index') }}">Cancel</a></button>
+ </div>
+ </div>
+ <!--
+ <div class="notification is-warning">
+ <button class="delete"></button>
+ Building Snapshots for some items may take a couple minutes. Please be patient!
+ </div>
+ -->
+</form>
+
+@endsection
\ No newline at end of file
diff --git a/resources/views/organization_types/index.edge b/resources/views/organization_types/index.edge
new file mode 100644
index 0000000..14492a3
--- /dev/null
+++ b/resources/views/organization_types/index.edge
@@ -0,0 +1,38 @@
+@layout('layouts.main')
+
+@section('content')
+
+<section class="box is-full-width">
+ <h3 class="is-size-3">Organization Type Actions</h3>
+ <ul>
+ <li><a href="{{ route('/organization_types/create') }}">Add Organization Type</a></li>
+ </ul>
+</section>
+
+<p>There are {{ types.length }} total orgnization types.</p>
+
+<section class="box">
+ <table class="table">
+ <thead class="thead">
+ <tr>
+ <th>Type</th>
+ <th>Action</th>
+ </tr>
+ </thead>
+ <tbody class="tbody">
+ @each(type in types)
+ <tr>
+ <td>{{ type.type }}</td>
+ <td>
+ <form action="{{ route('/orgnization_types.destroy', { id: type.id }) + '?_method=DELETE'}}" method="post">
+ {{ csrfField() }}
+ <button type="submit" name="button" class="is-small button is-danger" onclick="return confirm('Are you sure you want to delete this organization type?');">Delete</button>
+ </form>
+ </td>
+ </tr>
+ @endeach
+ </tbody>
+ </table>
+</section>
+
+@endsection
\ No newline at end of file
start/routes.js 3(+2 -1)
diff --git a/start/routes.js b/start/routes.js
index fe00ed1..16fa4bb 100644
--- a/start/routes.js
+++ b/start/routes.js
@@ -23,4 +23,5 @@ Route.on('/').render('index')
Route.resource('/themes','ThemeController')
Route.resource('/elements', 'ElementController')
Route.resource('/contacts', 'ContactController')
-Route.resource('/organizations', 'OrganizationController')
\ No newline at end of file
+Route.resource('/organizations', 'OrganizationController')
+Route.resource('/organization_types', 'OrganizationTypeController')
\ No newline at end of file