mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
New domain form
This commit is contained in:
parent
98cbae993d
commit
24e7beed5b
11 changed files with 66 additions and 1 deletions
10
app/assets/javascripts/app.js.coffee
Normal file
10
app/assets/javascripts/app.js.coffee
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
$(".js-registrars-typeahead").typeahead
|
||||||
|
source: (query, process) ->
|
||||||
|
$.get "/admin/registrars/search", {query: query}, (data) ->
|
||||||
|
process data
|
||||||
|
|
||||||
|
$(".js-contacts-typeahead").typeahead
|
||||||
|
source: (query, process) ->
|
||||||
|
$.get "/admin/contacts/search", {query: query}, (data) ->
|
||||||
|
process data
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#= require bootstrap-sprockets
|
#= require bootstrap-sprockets
|
||||||
#= require nprogress
|
#= require nprogress
|
||||||
#= require nprogress-turbolinks
|
#= require nprogress-turbolinks
|
||||||
|
#= require bootstrap3-typeahead.min
|
||||||
#= require_tree .
|
#= require_tree .
|
||||||
|
|
||||||
NProgress.configure
|
NProgress.configure
|
||||||
|
|
7
app/controllers/admin/contacts_controller.rb
Normal file
7
app/controllers/admin/contacts_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class Admin::ContactsController < ApplicationController
|
||||||
|
def search
|
||||||
|
c = Contact.arel_table
|
||||||
|
query_string = "%#{params[:query]}%"
|
||||||
|
render json: Contact.where(c[:code].matches(query_string)).pluck(:code)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,10 @@
|
||||||
class Admin::DomainsController < ApplicationController
|
class Admin::DomainsController < ApplicationController
|
||||||
before_action :set_domain, only: [:show]
|
before_action :set_domain, only: [:show]
|
||||||
|
|
||||||
|
def new
|
||||||
|
@domain = Domain.new
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@q = Domain.search(params[:q])
|
@q = Domain.search(params[:q])
|
||||||
@domains = @q.result.page(params[:page])
|
@domains = @q.result.page(params[:page])
|
||||||
|
|
7
app/controllers/admin/registrars_controller.rb
Normal file
7
app/controllers/admin/registrars_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class Admin::RegistrarsController < ApplicationController
|
||||||
|
def search
|
||||||
|
r = Registrar.arel_table
|
||||||
|
query_string = "%#{params[:query]}%"
|
||||||
|
render json: Registrar.where(r[:name].matches(query_string)).pluck(:name)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,2 +1,5 @@
|
||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def coffee_script_tag(&block)
|
||||||
|
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
18
app/views/admin/domains/new.haml
Normal file
18
app/views/admin/domains/new.haml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
%h2= t('shared.new_domain')
|
||||||
|
%hr
|
||||||
|
= form_for([:admin, @domain]) do |f|
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :name
|
||||||
|
= f.text_field(:name, class: 'form-control')
|
||||||
|
.form-group
|
||||||
|
= f.label :period
|
||||||
|
= f.text_field(:period, class: 'form-control')
|
||||||
|
.col-md-6
|
||||||
|
.form-group
|
||||||
|
= f.label :registrar
|
||||||
|
= f.text_field(:registrar, class: 'form-control js-registrars-typeahead', placeholder: t('shared.registrar_name'))
|
||||||
|
.form-group
|
||||||
|
= f.label :owner_contact
|
||||||
|
= f.text_field(:owner_contact, class: 'form-control js-contacts-typeahead', placeholder: t('shared.contact_code'))
|
|
@ -7,7 +7,6 @@
|
||||||
%meta{content: "Gitlab LTD", name: "author"}/
|
%meta{content: "Gitlab LTD", name: "author"}/
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
||||||
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
|
||||||
%link{href: "../../favicon.ico", rel: "icon"}/
|
%link{href: "../../favicon.ico", rel: "icon"}/
|
||||||
%title Eesti Interneti SA
|
%title Eesti Interneti SA
|
||||||
%body
|
%body
|
||||||
|
@ -51,4 +50,5 @@
|
||||||
.container
|
.container
|
||||||
= yield
|
= yield
|
||||||
|
|
||||||
|
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
||||||
|
|
||||||
|
|
|
@ -181,3 +181,6 @@ en:
|
||||||
delete: 'Delete'
|
delete: 'Delete'
|
||||||
are_you_sure: 'Are you sure?'
|
are_you_sure: 'Are you sure?'
|
||||||
back: 'Back'
|
back: 'Back'
|
||||||
|
new_domain: 'New domain'
|
||||||
|
registrar_name: 'Registrar name'
|
||||||
|
contact_code: 'Contact code'
|
||||||
|
|
|
@ -8,6 +8,17 @@ Rails.application.routes.draw do
|
||||||
namespace(:admin) do
|
namespace(:admin) do
|
||||||
resources :domains
|
resources :domains
|
||||||
resources :setting_groups
|
resources :setting_groups
|
||||||
|
resources :registrars do
|
||||||
|
collection do
|
||||||
|
get :search
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
resources :contacts do
|
||||||
|
collection do
|
||||||
|
get 'search'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# The priority is based upon order of creation: first created -> highest priority.
|
# The priority is based upon order of creation: first created -> highest priority.
|
||||||
|
|
1
vendor/assets/javascripts/bootstrap3-typeahead.min.js
vendored
Normal file
1
vendor/assets/javascripts/bootstrap3-typeahead.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue