New domain form

This commit is contained in:
Martin Lensment 2014-09-08 16:23:15 +03:00
parent 98cbae993d
commit 24e7beed5b
11 changed files with 66 additions and 1 deletions

View 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

View file

@ -4,6 +4,7 @@
#= require bootstrap-sprockets
#= require nprogress
#= require nprogress-turbolinks
#= require bootstrap3-typeahead.min
#= require_tree .
NProgress.configure

View 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

View file

@ -1,6 +1,10 @@
class Admin::DomainsController < ApplicationController
before_action :set_domain, only: [:show]
def new
@domain = Domain.new
end
def index
@q = Domain.search(params[:q])
@domains = @q.result.page(params[:page])

View 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

View file

@ -1,2 +1,5 @@
module ApplicationHelper
def coffee_script_tag(&block)
content_tag(:script, CoffeeScript.compile(capture(&block)).html_safe, :type => 'text/javascript')
end
end

View 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'))

View file

@ -7,7 +7,6 @@
%meta{content: "Gitlab LTD", name: "author"}/
= csrf_meta_tags
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
%link{href: "../../favicon.ico", rel: "icon"}/
%title Eesti Interneti SA
%body
@ -51,4 +50,5 @@
.container
= yield
= javascript_include_tag 'application', 'data-turbolinks-track' => true

View file

@ -181,3 +181,6 @@ en:
delete: 'Delete'
are_you_sure: 'Are you sure?'
back: 'Back'
new_domain: 'New domain'
registrar_name: 'Registrar name'
contact_code: 'Contact code'

View file

@ -8,6 +8,17 @@ Rails.application.routes.draw do
namespace(:admin) do
resources :domains
resources :setting_groups
resources :registrars do
collection do
get :search
end
end
resources :contacts do
collection do
get 'search'
end
end
end
# The priority is based upon order of creation: first created -> highest priority.

File diff suppressed because one or more lines are too long