adhoq 0.4.0 → 0.5.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55ebbfcb4634de6d7ff7b565a620aea07cdb739c
4
- data.tar.gz: 4a46756086ac03ff5f8564797fff26522fb0f4a2
3
+ metadata.gz: a6e80af86c7cb940f71f7e52519bfb230401a77c
4
+ data.tar.gz: 8ffc771c4e7d7dab5779ce9523a3057750baf712
5
5
  SHA512:
6
- metadata.gz: 19c49904e45e9eedf169134bc6564448e0974af82a61862bc8fffc33c3bd1a921cb976acf7c962e34b963b38ec99ad06f21b0d0c07ec6dd3bed30856901cec1c
7
- data.tar.gz: cae892aac89db0af6e29568fac5aac68c2adab131315fa87fdf38dd8a002e9397c8b85dd2864f4b09c0fb745799597d0a313c0c56e3e6288662d94977b6508b7
6
+ metadata.gz: 663808146b19b9804b2190ea04b7d7f36e97087884b515fc70a34248b8e73b4ad40fadce1bfdd0ac29443ca2faecf32852e408622a8a8f8fef4f80fc23129562
7
+ data.tar.gz: 0cce243729dc884e9f2f81ac1fa33f479db7f9fb92c5e617b1251bcaa3f919798b081dc7942303e749c4456dd4200b66a6420bb0972b9d03e22bf86c9bf6908b
@@ -16,5 +16,6 @@
16
16
  //= require ./bootstrap
17
17
  //= require ./previewer
18
18
  //= require ./current_tables
19
+ //= require queryEditor.bundle
19
20
 
20
21
  window.Adhoq = {}
@@ -18,6 +18,14 @@ class Previewer
18
18
  )
19
19
 
20
20
  source: ->
21
+ # NOTE: Sometimes the textarea is empty even if the monaco editor has some contents.
22
+ # That's why the editor source is preferred.
23
+ @editorSource() || @domSource()
24
+
25
+ editorSource: ->
26
+ Adhoq.editor && Adhoq.editor.getValue()
27
+
28
+ domSource: ->
21
29
  $(@el.data('source')).val()
22
30
 
23
31
  result: ->
@@ -11,11 +11,32 @@ module Adhoq
11
11
  reject {|klass| klass.abstract_class? || hidden_model_names.include?(klass.name) || klass.name.nil? }.
12
12
  sort_by(&:name)
13
13
 
14
- render layout: false
14
+ respond_to do |format|
15
+ format.html { render layout: false }
16
+ format.json { render json: tables_as_json(@ar_classes) }
17
+ end
15
18
  end
16
19
 
17
20
  private
18
21
 
22
+ def tables_as_json(ar_classes)
23
+ ar_classes.map {|ar_class|
24
+ {
25
+ table_name: ar_class.table_name,
26
+ columns: ar_class.columns.map {|column|
27
+ {
28
+ name: column.name,
29
+ type: column.type,
30
+ primary_key: column.name == ar_class.primary_key,
31
+ null: column.null,
32
+ limit: column.limit,
33
+ default: column.default
34
+ }
35
+ }
36
+ }
37
+ }
38
+ end
39
+
19
40
  def eager_load_models
20
41
  return unless Rails.env.development?
21
42
  [Rails.application, Adhoq::Engine].each(&:eager_load!)
@@ -1,5 +1,5 @@
1
1
  #current-tables
2
- a.loading[href=current_tables_path]
2
+ a.loading[href=current_tables_path(format: 'html')]
3
3
 
4
4
  javascript:
5
5
  $(function() {
@@ -7,8 +7,20 @@
7
7
  i.fa.fa-database.fa-pad-r
8
8
  | Show tables
9
9
 
10
+ .clearfix
11
+ a#disable_code_editor.pull-right(href='#')
12
+ i.fa.fa-edit
13
+ | Switch to Plain Editor
14
+
10
15
  .form-group
11
- = f.text_area :query, class: 'form-control', rows: 15, required: true
16
+ .form-control.query-editor
17
+ #query_field(
18
+ data-current-tables-path="#{current_tables_path}"
19
+ data-id="query_query"
20
+ data-name="query[query]"
21
+ data-placeholder="#{@query.persisted? ? 'Edit' : 'New'} query"
22
+ data-query="#{@query.query}"
23
+ )
12
24
 
13
25
  .modal.fade#nameAndDesc[role='dialog']
14
26
  .modal-dialog
@@ -85,9 +97,25 @@ ul.nav.nav-tabs[role='tablist']
85
97
 
86
98
  javascript:
87
99
  $(function() {
100
+ var element = document.getElementById('query_field');
101
+
102
+ Adhoq.editor = Adhoq.launchEditor(element);
103
+ Adhoq.installCompletion(element.dataset.currentTablesPath);
104
+
105
+ $('#disable_code_editor').on('click', function(e) {
106
+ e.preventDefault();
107
+
108
+ Adhoq.switchToTextareaEditor({
109
+ editor: Adhoq.editor,
110
+ element: element.parentNode,
111
+ content: Adhoq.editor.getModel().getValue()
112
+ });
113
+
114
+ e.target.remove();
115
+ });
116
+
88
117
  Adhoq.enablePreview($('#preview a.js-preview-button'));
89
118
  Adhoq.enablePreview($('#explain a.js-explain-button'));
90
119
 
91
120
  Adhoq.enablePreviewKeybordShortCut($('#query_query'), '#previews .tab-pane.active a:has(".fa-refresh")')
92
121
  });
93
-
@@ -12,5 +12,7 @@ module Adhoq
12
12
  g.test_framework :rspec, fixture: false
13
13
  g.fixture_replacement :factory_girl, dir: 'spec/factories'
14
14
  end
15
+
16
+ config.assets.paths << "#{__dir__}/../../query_editor/dist"
15
17
  end
16
18
  end
@@ -1,3 +1,3 @@
1
1
  module Adhoq
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0.beta1"
3
3
  end
@@ -13,6 +13,7 @@ Rails.backtrace_cleaner.remove_silencers!
13
13
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
14
14
 
15
15
  Capybara.default_driver = :poltergeist
16
+ Capybara.default_wait_time = 30
16
17
 
17
18
  RSpec.configure do |config|
18
19
  config.expect_with :rspec do |expectations|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhoq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyosuke MOROHASHI
@@ -493,9 +493,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
493
493
  version: '0'
494
494
  required_rubygems_version: !ruby/object:Gem::Requirement
495
495
  requirements:
496
- - - ">="
496
+ - - ">"
497
497
  - !ruby/object:Gem::Version
498
- version: '0'
498
+ version: 1.3.1
499
499
  requirements: []
500
500
  rubyforge_project:
501
501
  rubygems_version: 2.5.2.2