k_contactable 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9ffd79c301fdd888b204191f066c84a716d8a36d523a18007fd98aaf5476460e
4
+ data.tar.gz: d977d0aef013ff105d2886ec36719feb539ede56dc220ae610f48fb230381bb3
5
+ SHA512:
6
+ metadata.gz: 34592d53da8778bf68bc8bafeb100e9b100100fd7353c3ad76d3ba71a059c8623eeab76f222d9f1795d00fbb363361d8d4c21f8a293e1df2c856bb5e78546e8f
7
+ data.tar.gz: acbf5366f93ac863e3e38fd262d5d6fbf57f0a17c89da440a62631723d1d26f6e2664b22ea49702457b17b1e8288df47f11d4bb4a89e977d2792fa2d3a79e1c3
data/CHANGELOG.md ADDED
File without changes
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2021 Otoniel Reyes
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Taxable
2
+ Add contact support to your rails application.
3
+
4
+ ## Installation
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'k-contactable', '~> 0.1.0'
9
+ ```
10
+
11
+ And then execute:
12
+ ```bash
13
+ $ bundle
14
+ ```
15
+
16
+ Generate the installation:
17
+ ```bash
18
+ $ bin/rails g contactable:install
19
+ ```
20
+
21
+ ## Contributing
22
+ To contribute, just fork this repository, add/edit the code, and make a pull request. All contribution are welcome.
23
+
24
+ ## License
25
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
9
+
10
+ require "rake/testtask"
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = false
16
+ end
17
+
18
+ task default: :test
File without changes
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,58 @@
1
+ class ContactsController < ApplicationController
2
+ before_action :set_contact, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /contacts
5
+ def index
6
+ @contacts = Contact.all
7
+ end
8
+
9
+ # GET /contacts/1
10
+ def show
11
+ end
12
+
13
+ # GET /contacts/new
14
+ def new
15
+ @contact = Contact.new
16
+ end
17
+
18
+ # GET /contacts/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /contacts
23
+ def create
24
+ @contact = Contact.new(contact_params)
25
+
26
+ if @contact.save
27
+ redirect_to @contact, notice: 'Contact was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /contacts/1
34
+ def update
35
+ if @contact.update(contact_params)
36
+ redirect_to @contact, notice: 'Contact was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /contacts/1
43
+ def destroy
44
+ @contact.destroy
45
+ redirect_to contacts_url, notice: 'Contact was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_contact
51
+ @contact = Contact.find(params[:id])
52
+ end
53
+
54
+ # Only allow a list of trusted parameters through.
55
+ def contact_params
56
+ params.require(:contact).permit(:salutation, :firstname, :lastname, :work_phone, :mobile, :email)
57
+ end
58
+ end
@@ -0,0 +1,10 @@
1
+ module ContactsHelper
2
+ def salutations
3
+ return [
4
+ [I18n.translate('mr'), 'mr'],
5
+ [I18n.translate('mrs'), 'mrs'],
6
+ [I18n.translate('miss'), 'miss'],
7
+ [I18n.translate('dr'), 'dr']
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ class Contact < ApplicationRecord
2
+ belongs_to :contactable, polymorphic: true
3
+ end
@@ -0,0 +1,23 @@
1
+ <tr>
2
+ <td><%= contact.salutation %></td>
3
+ <td><%= contact.firstname %></td>
4
+ <td><%= contact.lastname %></td>
5
+ <td><%= link_to contact.work_phone, 'tel:' + contact.work_phone %></td>
6
+ <td><%= link_to contact.mobile, 'tel:' + contact.mobile %></td>
7
+ <td><%= link_to contact.email, 'mailto:' + contact.email %></td>
8
+ <td>
9
+ <div class="d-grid gap2">
10
+ <%= link_to t('show'), contact, class: 'btn btn-sm btn-outline-secondary' %>
11
+ </div>
12
+ </td>
13
+ <td>
14
+ <div class="d-grid gap2">
15
+ <%= link_to t('edit'), edit_contact_path(contact), class: 'btn btn-sm btn-outline-info' %>
16
+ </div>
17
+ </td>
18
+ <td>
19
+ <div class="d-grid gap2">
20
+ <%= link_to t('destroy'), contact, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-outline-danger' %>
21
+ </div>
22
+ </td>
23
+ </tr>
@@ -0,0 +1,70 @@
1
+ <%= form_with(model: contact) do |form| %>
2
+ <% if contact.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(contact.errors.count, "error") %> prohibited this contact from being saved:</h2>
5
+
6
+ <ul>
7
+ <% contact.errors.each do |error| %>
8
+ <li><%= error.full_message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="row row-cols-1 row-cols-md-3">
15
+ <div class="col">
16
+ <div class="input-group mb-3">
17
+ <span class="input-group-text">
18
+ <%= form.label :salutation, t('.salutation') %>
19
+ </span>
20
+ <%= form.select :salutation, salutations, {}, {class: 'form-control'} %>
21
+ </div>
22
+ </div>
23
+ <div class="col">
24
+ <div class="input-group mb-3">
25
+ <span class="input-group-text">
26
+ <%= form.label :firstname, t('.firstname') %>
27
+ </span>
28
+ <%= form.text_field :firstname, class: 'form-control' %>
29
+ </div>
30
+ </div>
31
+ <div class="col">
32
+ <div class="input-group mb-3">
33
+ <span class="input-group-text">
34
+ <%= form.label :lastname, t('.lastname') %>
35
+ </span>
36
+ <%= form.text_field :lastname, class: 'form-control' %>
37
+ </div>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="row row-cols-1 row-cols-md-2">
42
+ <div class="col">
43
+ <div class="input-group mb-3">
44
+ <span class="input-group-text">
45
+ <%= form.label :work_phone, t('.work_phone') %>
46
+ </span>
47
+ <%= form.telephone_field :work_phone, class: 'form-control' %>
48
+ </div>
49
+ </div>
50
+ <div class="col">
51
+ <div class="input-group mb-3">
52
+ <span class="input-group-text">
53
+ <%= form.label :mobile, t('.mobile') %>
54
+ </span>
55
+ <%= form.telephone_field :mobile, class: 'form-control' %>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <div class="input-group mb-3">
61
+ <span class="input-group-text">
62
+ <%= form.label :email, t('.email') %>
63
+ </span>
64
+ <%= form.email_field :email, class: 'form-control' %>
65
+ </div>
66
+
67
+ <div class="mb-3">
68
+ <%= form.submit t('save'), data: { disable_with: t('saving') }, class: 'btn btn-primary' %>
69
+ </div>
70
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1><%= t('.editing_contact') %></h1>
2
+
3
+ <%= render 'form', contact: @contact %>
4
+
5
+ <%= link_to t('show'), @contact, class: 'btn btn-outline-info' %>
6
+ <%= link_to t('back'), contacts_path, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,20 @@
1
+ <h1><%= t('.contacts') %></h1>
2
+
3
+ <table class="table table-hover table-striped my-3">
4
+ <thead>
5
+ <tr>
6
+ <th><%= t('.salutation') %></th>
7
+ <th><%= t('.firstname') %></th>
8
+ <th><%= t('.lastname') %></th>
9
+ <th><%= t('.work_phone') %></th>
10
+ <th><%= t('.mobile') %></th>
11
+ <th><%= t('.email') %></th>
12
+ <th colspan="3"></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <%= render @contacts %>
17
+ </tbody>
18
+ </table>
19
+
20
+ <%= link_to t('new_contact'), new_contact_path, class: 'btn btn-primary' %>
@@ -0,0 +1,5 @@
1
+ <h1><%= t('.new_contact') %></h1>
2
+
3
+ <%= render 'form', contact: @contact %>
4
+
5
+ <%= link_to t('back'), contacts_path, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,34 @@
1
+ <h1><%= t('contact_details') %></h1>
2
+
3
+ <div class="my-3">
4
+ <strong><%= t('.salutation') %>:</strong>
5
+ <p><%= @contact.salutation %></p>
6
+ </div>
7
+
8
+ <div class="my-3">
9
+ <strong><%= t('.firstname') %>:</strong>
10
+ <p><%= @contact.firstname %></p>
11
+ </div>
12
+
13
+ <div class="my-3">
14
+ <strong><%= t('.lastname') %>:</strong>
15
+ <p><%= @contact.lastname %></p>
16
+ </div>
17
+
18
+ <div class="my-3">
19
+ <strong><%= t('.work_phone') %>:</strong>
20
+ <p><%= link_to @contact.work_phone, 'tel:' + @contact.work_phone %></p>
21
+ </div>
22
+
23
+ <div class="my-3">
24
+ <strong><%= t('.mobile') %>:</strong>
25
+ <p><%= link_to @contact.mobile, 'tel:' + @contact.mobile %></p>
26
+ </div>
27
+
28
+ <div class="my-3">
29
+ <strong><%= t('.email') %>:</strong>
30
+ <p><%= link_to @contact.email, 'mailto:' + @contact.email %></p>
31
+ </div>
32
+
33
+ <%= link_to t('edit'), edit_contact_path(@contact), class: 'btn btn-outline-info' %>
34
+ <%= link_to t('back'), contacts_path, class: 'btn btn-outline-secondary' %>
@@ -0,0 +1,38 @@
1
+ en:
2
+ back: 'Back'
3
+ show: 'Show'
4
+ save: 'Save'
5
+ mr: 'Mr.'
6
+ mrs: 'Mrs.'
7
+ miss: 'Miss'
8
+ dr: 'Dr'
9
+ saving: 'Saving...'
10
+ destroy: 'Delete'
11
+ contacts:
12
+ form:
13
+ salutation: 'Salutation'
14
+ firstname: 'First Name'
15
+ lastname: 'Last Name'
16
+ work_phone: 'Work Phone'
17
+ mobile: 'Mobile'
18
+ email: 'Email'
19
+ index:
20
+ contacts: 'Contacts'
21
+ salutation: 'Salutation'
22
+ firstname: 'First Name'
23
+ lastname: 'Last Name'
24
+ work_phone: 'Work Phone'
25
+ mobile: 'Mobile'
26
+ email: 'Email'
27
+ edit:
28
+ editing_contact: 'Editing Contact'
29
+ new:
30
+ new_contact: 'New Contact'
31
+ show:
32
+ contact_details: 'Contact Details'
33
+ salutation: 'Salutation'
34
+ firstname: 'First Name'
35
+ lastname: 'Last Name'
36
+ work_phone: 'Work Phone'
37
+ mobile: 'Mobile'
38
+ email: 'Email'
@@ -0,0 +1,38 @@
1
+ es:
2
+ back: 'Atrás'
3
+ show: 'Mostrar'
4
+ save: 'Guardar'
5
+ mr: 'Sr.'
6
+ mrs: 'Sra.'
7
+ miss: 'Srta.'
8
+ dr: 'Dr'
9
+ saving: 'Guardando...'
10
+ destroy: 'Eliminar'
11
+ contacts:
12
+ form:
13
+ salutation: 'Saludo'
14
+ firstname: 'Nombre(s)'
15
+ lastname: 'Apellido(s)'
16
+ work_phone: 'Teléfono del Trabajo'
17
+ mobile: 'Celular'
18
+ email: 'Email'
19
+ index:
20
+ contacts: 'Contactos'
21
+ salutation: 'Saludo'
22
+ firstname: 'Nombre(s)'
23
+ lastname: 'Apellido(s)'
24
+ work_phone: 'Teléfono del Trabajo'
25
+ mobile: 'Celular'
26
+ email: 'Email'
27
+ edit:
28
+ editing_contact: 'Editando Contacto'
29
+ new:
30
+ new_contact: 'Registrar Contacto'
31
+ show:
32
+ contact_details: 'Detalles del Contacto'
33
+ salutation: 'Saludo'
34
+ firstname: 'Nombre(s)'
35
+ lastname: 'Apellido(s)'
36
+ work_phone: 'Teléfono del Trabajo'
37
+ mobile: 'Celular'
38
+ email: 'Email'
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ resources :contacts
3
+ end
@@ -0,0 +1,15 @@
1
+ class CreateContacts < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :contacts do |t|
4
+ t.string :salutation
5
+ t.string :firstname
6
+ t.string :lastname
7
+ t.string :work_phone
8
+ t.string :mobile
9
+ t.string :email
10
+ t.references :contactable, polymorphic: true
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require 'rails/generators/base'
2
+
3
+ module KContactable
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def copy_migrations
9
+ rake "k_contactable_engine:install:migrations"
10
+ rake "db:migrate"
11
+ end
12
+
13
+ def copy_locales
14
+ copy_file "../../../../config/locales/en.yml", "config/locales/contactable.en.yml"
15
+ copy_file "../../../../config/locales/es.yml", "config/locales/contactable.es.yml"
16
+ end
17
+
18
+ def add_route
19
+ # Sisnce this engine isn't mountable, don't need to be mounted, so remove this line
20
+ # route "mount Contactable::Engine => '/contacts'"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ require "k_contactable/version"
2
+ require "k_contactable/engine"
3
+
4
+ module KContactable
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,4 @@
1
+ module KContactable
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module KContactable
2
+ VERSION = '0.1.2'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :contactable do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: k_contactable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - kenliten
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.4
27
+ description: Simple contact management engine for rails applications
28
+ email:
29
+ - kenliten@otonielreyes.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - MIT-LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - app/assets/config/contactable_manifest.js
39
+ - app/assets/stylesheets/contacts.css
40
+ - app/controllers/contacts_controller.rb
41
+ - app/helpers/contacts_helper.rb
42
+ - app/models/contact.rb
43
+ - app/views/contacts/_contact.html.erb
44
+ - app/views/contacts/_form.html.erb
45
+ - app/views/contacts/edit.html.erb
46
+ - app/views/contacts/index.html.erb
47
+ - app/views/contacts/new.html.erb
48
+ - app/views/contacts/show.html.erb
49
+ - config/locales/en.yml
50
+ - config/locales/es.yml
51
+ - config/routes.rb
52
+ - db/migrate/20210822232510_create_contacts.rb
53
+ - lib/generators/k_contactable/install_generator.rb
54
+ - lib/k_contactable.rb
55
+ - lib/k_contactable/engine.rb
56
+ - lib/k_contactable/version.rb
57
+ - lib/tasks/k-contactable_tasks.rake
58
+ homepage: https://contactable.kenliten.website
59
+ licenses:
60
+ - MIT
61
+ metadata:
62
+ homepage_uri: https://contactable.kenliten.website
63
+ source_code_uri: https://github.com/kenliten/contactable
64
+ changelog_uri: https://github.com/kenliten/contactable/blob/main/CHANGELOG.md
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.2.15
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Add contact management capabilities to your rails application
84
+ test_files: []