qube_rails 0.2.0 → 0.3.0

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +321 -0
  3. data/README.md +406 -76
  4. data/app/assets/javascripts/qube_rails/question.js +469 -43
  5. data/app/assets/stylesheets/qube_rails.css +1349 -912
  6. data/app/controllers/qube_rails/connections_controller.rb +42 -9
  7. data/app/controllers/qube_rails/questions_controller.rb +39 -7
  8. data/app/controllers/qube_rails/runs_controller.rb +4 -3
  9. data/app/controllers/qube_rails/storyboard_controller.rb +1 -1
  10. data/app/models/qube_rails/connection.rb +131 -9
  11. data/app/models/qube_rails/quickbooks_record.rb +22 -0
  12. data/app/models/qube_rails/run.rb +28 -10
  13. data/app/views/qube_rails/_error.html.erb +2 -2
  14. data/app/views/qube_rails/_manage_connection.html.erb +19 -0
  15. data/app/views/qube_rails/_question.html.erb +4 -1
  16. data/app/views/qube_rails/question/_choice.html.erb +34 -11
  17. data/app/views/qube_rails/question/_disclosure.html.erb +7 -0
  18. data/app/views/qube_rails/question/_exit_button.html.erb +8 -0
  19. data/app/views/qube_rails/question/_field.html.erb +4 -3
  20. data/app/views/qube_rails/question/_footer.html.erb +12 -4
  21. data/app/views/qube_rails/question/_inline_search.html.erb +12 -0
  22. data/app/views/qube_rails/question/_pick.html.erb +29 -6
  23. data/app/views/qube_rails/question/_picks.html.erb +2 -1
  24. data/app/views/qube_rails/question/_question.html.erb +31 -7
  25. data/app/views/qube_rails/question/_submit.html.erb +9 -0
  26. data/app/views/qube_rails/question/fields/_boolean.html.erb +2 -2
  27. data/app/views/qube_rails/question/fields/_number.html.erb +2 -2
  28. data/app/views/qube_rails/question/fields/_rows.html.erb +17 -4
  29. data/app/views/qube_rails/question/fields/_search.html.erb +6 -3
  30. data/app/views/qube_rails/question/fields/_select.html.erb +6 -5
  31. data/app/views/qube_rails/question/fields/_text.html.erb +2 -2
  32. data/app/views/qube_rails/question/rows/_segmented.html.erb +3 -1
  33. data/app/views/qube_rails/run_status/_detail.html.erb +5 -1
  34. data/app/views/qube_rails/run_status/_status.html.erb +5 -2
  35. data/app/views/qube_rails/storyboard/show.html.erb +4 -3
  36. data/config/locales/en.yml +30 -1
  37. data/config/routes.rb +2 -0
  38. data/db/migrate/20261031000000_add_qube_connection_type_and_run_headline.rb +12 -0
  39. data/db/migrate/20261124000000_add_qube_company_file_change.rb +17 -0
  40. data/lib/generators/qube_rails/templates/connection_events.rb.tt +17 -1
  41. data/lib/generators/qube_rails/templates/initializer.rb.tt +12 -4
  42. data/lib/qube_rails/configuration.rb +5 -2
  43. data/lib/qube_rails/connection_events.rb +70 -7
  44. data/lib/qube_rails/engine.rb +1 -0
  45. data/lib/qube_rails/link_check.rb +274 -0
  46. data/lib/qube_rails/operation.rb +116 -32
  47. data/lib/qube_rails/question_view.rb +293 -35
  48. data/lib/qube_rails/request.rb +2 -0
  49. data/lib/qube_rails/rows_view.rb +18 -5
  50. data/lib/qube_rails/run_status_view.rb +12 -7
  51. data/lib/qube_rails/storyboard/ask_about_add.json +9 -11
  52. data/lib/qube_rails/storyboard/choose.json +10 -7
  53. data/lib/qube_rails/storyboard/enum_select.json +5 -4
  54. data/lib/qube_rails/storyboard/missing_record.json +11 -14
  55. data/lib/qube_rails/storyboard/name_clash.json +51 -21
  56. data/lib/qube_rails/storyboard/near_match.json +18 -15
  57. data/lib/qube_rails/storyboard/number_boolean.json +5 -4
  58. data/lib/qube_rails/storyboard/record_search.json +15 -16
  59. data/lib/qube_rails/storyboard/refusal.json +15 -18
  60. data/lib/qube_rails/storyboard/rows.json +45 -31
  61. data/lib/qube_rails/storyboard.rb +28 -7
  62. data/lib/qube_rails/sync_status.rb +16 -3
  63. data/lib/qube_rails/version.rb +1 -1
  64. data/lib/qube_rails/view_helpers.rb +4 -2
  65. data/lib/qube_rails.rb +11 -2
  66. metadata +10 -2
@@ -1,20 +1,43 @@
1
1
  <%# One choice (a QubeRails::ChoiceView): a form posting choice=<id> and data[...] for its fields
2
2
  to choice.action_url, with your CSRF token. Its button is choice.style's (:primary, :secondary
3
- or :ghost), with that ui_classes piece (choice.button_piece). %>
3
+ or :ghost), with that ui_classes piece (choice.button_piece). data-qube-choice-role is QuBe
4
+ Sync's role for it, when the prompt has roles.
5
+ A form choice ends in its button row (.qube-choice-actions): cancel on the left, its submit on
6
+ the right, with the exits passed as exits: (their buttons name their own forms, form=). With
7
+ detached: true it renders only the form, for a button elsewhere to submit. %>
8
+ <% exits = local_assigns[:exits] || [] %>
9
+ <% detached = local_assigns[:detached] %>
10
+ <% row = choice.kind == :form %>
4
11
  <form class="<%= qube_classes(:choice, "qube-choice", choice.kind == :form ? "qube-choice-form" : nil) %>" method="post"
5
- action="<%= choice.action_url %>" data-qube-choice="<%= choice.id %>" data-qube-choice-kind="<%= choice.kind %>">
12
+ action="<%= choice.action_url %>" id="<%= choice.form_id %>" data-qube-choice="<%= choice.id %>" data-qube-choice-kind="<%= choice.kind %>"<% if choice.role %> data-qube-choice-role="<%= choice.role %>"<% end %><%= " hidden" if detached %>>
6
13
  <%= hidden_field_tag request_forgery_protection_token, form_authenticity_token, id: nil %>
7
14
  <%= hidden_field_tag :choice, choice.id, id: nil %>
8
- <% choice.fields.each do |field| %>
15
+ <% unless detached %>
16
+ <% choice.fields.each do |field| %>
9
17
  <%= render field.partial, field: field %>
10
- <% end %>
11
- <button type="submit" class="<%= qube_classes(choice.button_piece, "qube-choice-button") %>" data-qube-button="<%= choice.style %>">
12
- <%= choice.label %>
13
- <% if choice.detail %>
14
- <span class="<%= qube_classes(:choice_detail, "qube-choice-detail") %>"><%= choice.detail %></span>
15
- <% end %>
16
- </button>
17
- <% if choice.description %>
18
+ <% end %>
19
+ <% if row %>
20
+ <% if choice.description %>
21
+ <p class="<%= qube_classes(:choice_description, "qube-choice-description") %>"><%= choice.description %></p>
22
+ <% end %>
23
+ <div class="<%= qube_classes(:choice_actions, "qube-choice-actions") %>" data-qube-actions>
24
+ <div class="qube-choice-actions-start">
25
+ <% exits.select(&:cancel?).each do |exit_choice| %>
26
+ <%= render "qube_rails/question/exit_button", choice: exit_choice %>
27
+ <% end %>
28
+ </div>
29
+ <div class="qube-choice-actions-end" data-qube-actions-end>
30
+ <% exits.reject(&:cancel?).each do |exit_choice| %>
31
+ <%= render "qube_rails/question/exit_button", choice: exit_choice %>
32
+ <% end %>
33
+ <%= render "qube_rails/question/submit", choice: choice %>
34
+ </div>
35
+ </div>
36
+ <% else %>
37
+ <%= render "qube_rails/question/submit", choice: choice %>
38
+ <% if choice.description %>
18
39
  <p class="<%= qube_classes(:choice_description, "qube-choice-description") %>"><%= choice.description %></p>
40
+ <% end %>
41
+ <% end %>
19
42
  <% end %>
20
43
  </form>
@@ -0,0 +1,7 @@
1
+ <%# A form after a promoted row (question.disclosed: a name clash's rename), behind "or <its
2
+ label>…". Opened, its submit is the main action and the row's button steps back (stylesheet);
3
+ a refused answer for it opens it, and the script puts the focus in its first field. %>
4
+ <details class="qube-choice-disclosure" data-qube-disclosure<%= " open" if choice.refused? %>>
5
+ <summary class="<%= qube_classes(:button_ghost, "qube-choice-button") %>" data-qube-button="ghost"><%= QubeRails.t("question.disclose_choice", label: question.mid_sentence(choice.label)) %></summary>
6
+ <%= render "qube_rails/question/choice", question: question, choice: choice %>
7
+ </details>
@@ -0,0 +1,8 @@
1
+ <%# An exit's button in a form choice's row: it submits the exit's own form (form=), rendered
2
+ detached after the question's forms. %>
3
+ <button type="submit" form="<%= choice.form_id %>" class="<%= qube_classes(choice.button_piece, "qube-choice-button") %>" data-qube-button="<%= choice.style %>" data-qube-exit="<%= choice.id %>"<% if choice.role %> data-qube-choice-role="<%= choice.role %>"<% end %>>
4
+ <%= choice.label %>
5
+ <% if choice.detail %>
6
+ <span class="<%= qube_classes(:choice_detail, "qube-choice-detail") %>"><%= choice.detail %></span>
7
+ <% end %>
8
+ </button>
@@ -1,12 +1,13 @@
1
- <%# The wrapper every field piece renders its control (control, HTML) in: a choice's field gets
2
- its label; inside a rows table, the control stands alone. %>
1
+ <%# The wrapper every field piece renders its control (control, HTML) in, with its label; a field
2
+ that isn't required says "(optional)" (question.optional) after it (not a checkbox). %>
3
3
  <% if field.labelled? %>
4
4
  <div class="<%= qube_classes(:field, "qube-field", "qube-field-#{field.type}") %>">
5
5
  <% if field.type == "boolean" %>
6
6
  <%= control %>
7
7
  <%= label_tag field.dom_id, field.label, class: qube_classes(:label, "qube-label") %>
8
8
  <% else %>
9
- <%= label_tag field.dom_id, field.label, class: qube_classes(:label, "qube-label") %>
9
+ <% optional = field.optional? ? tag.span(QubeRails.t("question.optional"), class: "qube-optional") : nil %>
10
+ <%= label_tag field.dom_id, safe_join([field.label, optional].compact, " "), class: qube_classes(:label, "qube-label") %>
10
11
  <%= control %>
11
12
  <% end %>
12
13
  </div>
@@ -1,7 +1,15 @@
1
- <%# The exits (question.exits: none of these, cancel and the like) in a row; in a plain question
2
- (no picks, no forms) every choice, the first primary. %>
1
+ <%# The exits (question.exits) in one row: cancel on the left, the rest (decline and the like)
2
+ on the right. In a plain question (no picks, no forms) every choice, the first primary. With
3
+ descriptions they stack, cancel last. %>
3
4
  <div class="<%= qube_classes(:choice_footer, "qube-choice-footer") %>"<%= " data-qube-plain" if question.plain? %>>
4
- <% question.exits.each do |choice| %>
5
- <%= render "qube_rails/question/choice", question: question, choice: choice %>
5
+ <div class="qube-choice-footer-start">
6
+ <% question.exits.select(&:cancel?).each do |choice| %>
7
+ <%= render "qube_rails/question/choice", question: question, choice: choice %>
6
8
  <% end %>
9
+ </div>
10
+ <div class="qube-choice-footer-end">
11
+ <% question.exits.reject(&:cancel?).each do |choice| %>
12
+ <%= render "qube_rails/question/choice", question: question, choice: choice %>
13
+ <% end %>
14
+ </div>
7
15
  </div>
@@ -0,0 +1,12 @@
1
+ <%# A search beside offered records (question.searches): its box alone under them, "Search
2
+ QuickBooks…", its label for screen readers. It has no submit: the script puts the match
3
+ picked in it as a row with the offered records, whose "Use this one" answers. Hidden until the
4
+ script runs: without it the box can't search. %>
5
+ <form class="<%= qube_classes(:choice, "qube-choice", "qube-search-inline") %>" method="post" action="<%= choice.action_url %>"
6
+ id="<%= choice.form_id %>" data-qube-choice="<%= choice.id %>" data-qube-choice-kind="form" data-qube-choice-role="<%= choice.role %>" data-qube-needs-script hidden>
7
+ <%= hidden_field_tag request_forgery_protection_token, form_authenticity_token, id: nil %>
8
+ <%= hidden_field_tag :choice, choice.id, id: nil %>
9
+ <% choice.fields.each do |field| %>
10
+ <%= render field.partial, field: field %>
11
+ <% end %>
12
+ </form>
@@ -1,19 +1,42 @@
1
1
  <%# One pick (a QubeRails::ChoiceView of kind :pick): an option row, a form posting choice=<id>
2
- to choice.action_url with your CSRF token. %>
2
+ to choice.action_url with your CSRF token. An offered record (choice.style set) ends in a
3
+ "Use this one" button: the first primary, the rest secondary. A choice about one record shows
4
+ its title, lines and facts, and its action as the button. An offered record's button is its
5
+ only target, described by the record's name; a row without one is a button whole. A search box's picked match
6
+ (choice.slot?) is hidden and empty until the script fills it. %>
3
7
  <form class="qube-choice qube-pick-form" method="post" action="<%= choice.action_url %>" role="listitem"
4
- data-qube-choice="<%= choice.id %>" data-qube-choice-kind="pick">
8
+ data-qube-choice="<%= choice.id %>" data-qube-choice-kind="pick"<% if choice.role %> data-qube-choice-role="<%= choice.role %>"<% end %><%= " hidden" if choice.slot? %>>
5
9
  <%= hidden_field_tag request_forgery_protection_token, form_authenticity_token, id: nil %>
6
10
  <%= hidden_field_tag :choice, choice.id, id: nil %>
11
+ <% choice.data.each do |name, value| %>
12
+ <%= hidden_field_tag name, value, id: nil %>
13
+ <% end %>
14
+ <% if choice.style %>
15
+ <div class="<%= qube_classes(:pick, "qube-pick") %>">
16
+ <% else %>
7
17
  <button type="submit" class="<%= qube_classes(:pick, "qube-pick") %>">
18
+ <% end %>
8
19
  <span class="qube-pick-text">
9
- <span class="qube-pick-label"><%= choice.label %></span>
10
- <% if choice.detail %>
11
- <span class="<%= qube_classes(:pick_detail, "qube-pick-detail") %>"><%= choice.detail %></span>
20
+ <span class="qube-pick-label"<% if choice.style %> id="<%= choice.label_id %>"<% end %>><%= choice.title || choice.label %></span>
21
+ <% if choice.lines.any? || choice.facts.any? %>
22
+ <% choice.lines.each do |line| %>
23
+ <span class="<%= qube_classes(:pick_detail, "qube-pick-detail", "qube-pick-line") %>"><%= safe_join(choice.detail_parts(line).map { |part| tag.span(part, class: "qube-detail-part") }, " ") %></span>
24
+ <% end %>
25
+ <% if choice.facts.any? %>
26
+ <span class="qube-pick-facts"><% choice.facts.each do |fact| %><span class="qube-pick-fact"><span class="qube-pick-fact-label"><%= fact.label %></span> <%= fact.value %></span><% end %></span>
27
+ <% end %>
28
+ <% elsif choice.detail || choice.slot? %>
29
+ <span class="<%= qube_classes(:pick_detail, "qube-pick-detail") %>"><%= safe_join(choice.detail_parts.map { |part| tag.span(part, class: "qube-detail-part") }, " ") %></span>
12
30
  <% end %>
13
31
  <% if choice.description %>
14
32
  <span class="qube-pick-description"><%= choice.description %></span>
15
33
  <% end %>
16
34
  </span>
17
- <span class="<%= qube_classes(:pick_action, "qube-pick-action") %>"><%= QubeRails.t("question.use_pick") %></span>
35
+ <% if choice.style %>
36
+ <button type="submit" class="<%= qube_classes(choice.button_piece, "qube-pick-action", "qube-choice-button") %>" data-qube-button="<%= choice.style %>" data-qube-offered="<%= choice.style %>" aria-describedby="<%= choice.label_id %>"><%= choice.action || QubeRails.t("question.use_pick") %></button>
37
+ </div>
38
+ <% else %>
39
+ <span class="<%= qube_classes(:pick_action, "qube-pick-action") %>"><%= choice.action || QubeRails.t("question.use_pick") %></span>
18
40
  </button>
41
+ <% end %>
19
42
  </form>
@@ -1,4 +1,5 @@
1
- <%# The question's picks (question.picks): option rows, one form each. %>
1
+ <%# The question's picks (question.picks): option rows, one form each. The question's message says
2
+ what they are, so they have no heading. %>
2
3
  <div class="<%= qube_classes(:picks, "qube-picks") %>" role="list">
3
4
  <% question.picks.each do |choice| %>
4
5
  <%= render "qube_rails/question/pick", question: question, choice: choice %>
@@ -1,8 +1,13 @@
1
1
  <%# A question (a QubeRails::QuestionView): a refusal, its message, what it's about, then its
2
- choices by kind: the picks (option rows), each form choice ("or" between), and the exits in a
3
- footer. A question with neither picks nor forms shows its choices in one row. %>
4
- <section class="<%= qube_classes(:question, "qube-question") %>" data-qube-question="<%= question.token %>">
5
- <%= render "qube_rails/error", message: question.error %>
2
+ choices by kind: the picks (option rows), a search box under offered records (question.
3
+ searches), a decline beside them (question.alongside), each form choice ("or" between), the
4
+ forms behind "or <its label>…" (question.disclosed), and the exits in a footer. With one form
5
+ and no picks, the exits share that form's button row instead (question.joined_form). A
6
+ question with neither picks nor forms shows its choices in one row.
7
+ data-qube-button-*-class are the script's, for swapping a button's weight. %>
8
+ <section class="<%= qube_classes(:question, "qube-question") %>" data-qube-question="<%= question.token %>"
9
+ data-qube-button-class="<%= qube_classes(:button) %>" data-qube-button-secondary-class="<%= qube_classes(:button_secondary) %>">
10
+ <%= render "qube_rails/error", message: question.error, id: question.error_id %>
6
11
  <%= render "qube_rails/question/message", question: question %>
7
12
  <% if question.details.any? %>
8
13
  <%= render "qube_rails/question/details", question: question %>
@@ -11,13 +16,32 @@
11
16
  <% if question.picks.any? %>
12
17
  <%= render "qube_rails/question/picks", question: question %>
13
18
  <% end %>
19
+ <% question.searches.each do |choice| %>
20
+ <%= render "qube_rails/question/inline_search", question: question, choice: choice %>
21
+ <% end %>
22
+ <% if question.alongside.any? %>
23
+ <div class="qube-choice-alongside">
24
+ <% question.alongside.each do |choice| %>
25
+ <%= render "qube_rails/question/choice", question: question, choice: choice %>
26
+ <% end %>
27
+ </div>
28
+ <% end %>
29
+ <% joined = question.joined_form %>
14
30
  <% question.forms.each_with_index do |choice, n| %>
15
- <% if n.positive? || question.picks.any? %>
31
+ <% if question.divided?(choice, n) %>
16
32
  <div class="<%= qube_classes(:choice_divider, "qube-choice-divider") %>" role="separator"><span><%= QubeRails.t("question.or") %></span></div>
17
33
  <% end %>
18
- <%= render "qube_rails/question/choice", question: question, choice: choice %>
34
+ <%= render "qube_rails/question/choice", question: question, choice: choice,
35
+ exits: (choice.equal?(joined) ? question.exits : []) %>
19
36
  <% end %>
20
- <% if question.exits.any? %>
37
+ <% question.disclosed.each do |choice| %>
38
+ <%= render "qube_rails/question/disclosure", question: question, choice: choice %>
39
+ <% end %>
40
+ <% if joined %>
41
+ <% question.exits.each do |choice| %>
42
+ <%= render "qube_rails/question/choice", question: question, choice: choice, detached: true %>
43
+ <% end %>
44
+ <% elsif question.exits.any? %>
21
45
  <%= render "qube_rails/question/footer", question: question %>
22
46
  <% end %>
23
47
  </div>
@@ -0,0 +1,9 @@
1
+ <%# A choice's own submit, in its form. A rows form's submit waits for the behaviour script
2
+ (hidden until it runs: a rows field can't be answered without it); a search's ("Use this
3
+ one") until a match is picked (choice.waits_for_pick?), which the script shows. %>
4
+ <button type="submit" class="<%= qube_classes(choice.button_piece, "qube-choice-button") %>" data-qube-button="<%= choice.style %>"<% if choice.rows? %> data-qube-needs-script hidden<% elsif choice.waits_for_pick? %> hidden<% end %>>
5
+ <%= choice.label %>
6
+ <% if choice.detail %>
7
+ <span class="<%= qube_classes(:choice_detail, "qube-choice-detail") %>"><%= choice.detail %></span>
8
+ <% end %>
9
+ </button>
@@ -1,7 +1,7 @@
1
1
  <%# A checkbox: ticked posts "true", sent as true; unticked, false. %>
2
2
  <% control = capture do %>
3
- <%= check_box_tag field.input_name, "true", false, id: field.dom_id, disabled: field.disabled,
3
+ <%= check_box_tag field.input_name, "true", field.value.to_s == "true", id: field.dom_id, disabled: field.disabled,
4
4
  class: qube_classes(:checkbox, "qube-checkbox", field.cell? ? "qube-rows-input" : nil),
5
- "aria-label": (field.labelled? ? nil : field.label), data: field.data %>
5
+ "aria-label": (field.labelled? ? nil : field.label), data: field.data, **field.aria_invalid %>
6
6
  <% end %>
7
7
  <%= render "qube_rails/question/field", field: field, control: control %>
@@ -1,7 +1,7 @@
1
1
  <%# A number field: posted as typed, sent as a number. %>
2
2
  <% control = capture do %>
3
- <%= number_field_tag field.input_name, nil, id: field.dom_id, step: "any", required: field.required,
3
+ <%= number_field_tag field.input_name, field.value, id: field.dom_id, step: "any", required: field.required,
4
4
  disabled: field.disabled, class: qube_classes(:input, "qube-input", field.cell? ? "qube-rows-input" : nil),
5
- "aria-label": (field.labelled? ? nil : field.label), data: field.data %>
5
+ "aria-label": (field.labelled? ? nil : field.label), data: field.data, **field.aria_invalid %>
6
6
  <% end %>
7
7
  <%= render "qube_rails/question/field", field: field, control: control %>
@@ -1,12 +1,25 @@
1
1
  <%# A rows field (field.rows, a QubeRails::RowsView): a block per record with the fields it asks,
2
2
  posted as data[<field>][<row key>][<column>]. A field shows only while its "when" holds. "Set
3
- all to:" sets the segmented column on every row, and "Use for all" copies one row's value to
4
- the others (the behaviour script). %>
3
+ all to:" sets the segmented column on every row, and "Use for the other records too" copies one
4
+ row's value to the others' empty field and says so (the behaviour script). With the script, more than one row shows one at a time:
5
+ the data-qube-text-step/-back/-next words and the button classes are for its step line and
6
+ Back / Next. It needs the script: hidden until the script shows it, with a <noscript> line
7
+ saying so. %>
5
8
  <% rows = field.rows %>
6
9
  <% set_all = rows.set_all %>
7
- <div class="<%= qube_classes(:field, "qube-field", "qube-rows-field") %>" data-qube-rows
8
- data-qube-text-use-for-all="<%= QubeRails.t("question.use_for_all", count: "%{count}") %>">
10
+ <noscript><p class="<%= qube_classes(:error, "qube-error") %>"><%= QubeRails.t("question.needs_script") %></p></noscript>
11
+ <div class="<%= qube_classes(:field, "qube-field", "qube-rows-field") %>" data-qube-rows data-qube-needs-script hidden
12
+ data-qube-text-use-for-all-one="<%= QubeRails.t("question.use_for_all", count: 1) %>"
13
+ data-qube-text-use-for-all-other="<%= QubeRails.t("question.use_for_all", count: "%{count}") %>"
14
+ data-qube-text-used-for-all-one="<%= QubeRails.t("question.used_for_all", count: 1) %>"
15
+ data-qube-text-used-for-all-other="<%= QubeRails.t("question.used_for_all", count: "%{count}") %>"
16
+ data-qube-text-step="<%= rows.ui_text(:step, name: "%{name}", position: "%{position}", count: "%{count}") %>"
17
+ data-qube-text-back="<%= QubeRails.t("question.back") %>" data-qube-text-next="<%= QubeRails.t("question.next") %>"
18
+ data-qube-button-class="<%= qube_classes(:button, "qube-choice-button") %>"
19
+ data-qube-button-secondary-class="<%= qube_classes(:button_secondary, "qube-choice-button") %>">
20
+ <% unless rows.label.strip.empty? %>
9
21
  <p class="<%= qube_classes(:label, "qube-rows-label") %>"><%= rows.label %></p>
22
+ <% end %>
10
23
  <% if set_all %>
11
24
  <div class="qube-rows-set-all" data-qube-rows-set-all="<%= set_all.name %>">
12
25
  <span class="qube-rows-set-all-label"><%= QubeRails.t("question.set_all") %></span>
@@ -1,12 +1,14 @@
1
1
  <%# A record field: what the user types is looked up at field.search_url (GET ?field=&q=&row=,
2
2
  answering [{value, label, detail}]), and the match they pick fills the hidden input posted as
3
3
  field.input_name. The behaviour script keys on the data-qube-* attributes; the box's
4
- data-qube-text-* attributes are its words (I18n's qube_rails.question.*). %>
4
+ data-qube-text-* attributes are its words (I18n's qube_rails.question.*). Under offered records
5
+ (field.inline?) it says "Search QuickBooks…" and isn't required. %>
5
6
  <% inputs = capture do %>
6
7
  <%= tag.input(type: "search", id: field.dom_id, class: qube_classes(:input, "qube-search-input"), maxlength: 100,
7
- autocomplete: "off", required: field.required, disabled: field.disabled,
8
+ placeholder: field.placeholder, autocomplete: "off", required: field.required, disabled: field.disabled,
8
9
  role: "combobox", "aria-autocomplete": "list", "aria-expanded": "false",
9
- "aria-label": (field.labelled? ? nil : field.label), data: { "qube-search-input" => "" }) %>
10
+ "aria-label": (field.labelled? ? nil : field.label), data: { "qube-search-input" => "" },
11
+ **field.aria_invalid) %>
10
12
  <%= tag.input(type: "hidden", name: field.input_name, disabled: field.disabled,
11
13
  class: ["qube-search-value", field.cell? ? "qube-rows-input" : nil].compact.join(" "),
12
14
  data: field.data.merge("qube-search-value" => "")) %>
@@ -19,5 +21,6 @@
19
21
  "qube-text-no-matches" => QubeRails.t("question.no_matches"),
20
22
  "qube-text-searching" => QubeRails.t("question.searching"),
21
23
  "qube-text-search-failed" => QubeRails.t("question.search_failed"),
24
+ "qube-text-search-changed" => QubeRails.t("question.search_changed"),
22
25
  "qube-text-pick-a-match" => QubeRails.t("question.pick_a_match") }.compact) %>
23
26
  <%= render "qube_rails/question/field", field: field, control: control %>
@@ -1,8 +1,9 @@
1
- <%# A fixed list (field.options, each value and label), with a blank first. %>
1
+ <%# A fixed list (field.options, each value and label), with "Choose…" (question.choose) first;
2
+ field.value (a column's default, or what a refused answer had) starts selected. %>
2
3
  <% control = capture do %>
3
- <%= select_tag field.input_name, options_for_select(field.options.map { |o| [o.label, o.value] }),
4
- id: field.dom_id, include_blank: true, required: field.required, disabled: field.disabled,
5
- class: qube_classes(:select, "qube-select", field.cell? ? "qube-rows-input" : nil),
6
- "aria-label": (field.labelled? ? nil : field.label), data: field.data %>
4
+ <%= select_tag field.input_name, options_for_select(field.options.map { |o| [o.label, o.value] }, field.value),
5
+ id: field.dom_id, include_blank: QubeRails.t("question.choose"), required: field.required,
6
+ disabled: field.disabled, class: qube_classes(:select, "qube-select", field.cell? ? "qube-rows-input" : nil),
7
+ "aria-label": (field.labelled? ? nil : field.label), data: field.data, **field.aria_invalid %>
7
8
  <% end %>
8
9
  <%= render "qube_rails/question/field", field: field, control: control %>
@@ -1,7 +1,7 @@
1
1
  <%# A text field. %>
2
2
  <% control = capture do %>
3
- <%= text_field_tag field.input_name, nil, id: field.dom_id, required: field.required, disabled: field.disabled,
3
+ <%= text_field_tag field.input_name, field.value, id: field.dom_id, required: field.required, disabled: field.disabled,
4
4
  class: qube_classes(:input, "qube-input", field.cell? ? "qube-rows-input" : nil),
5
- "aria-label": (field.labelled? ? nil : field.label), data: field.data %>
5
+ "aria-label": (field.labelled? ? nil : field.label), data: field.data, **field.aria_invalid %>
6
6
  <% end %>
7
7
  <%= render "qube_rails/question/field", field: field, control: control %>
@@ -1,11 +1,13 @@
1
1
  <%# A short list (field.options, at most three) in a row as a segmented control: radios posted
2
- as field.input_name, the column's label their group's name for screen readers. %>
2
+ as field.input_name, the column's label their group's name for screen readers; field.value
3
+ (the column's default) starts checked. %>
3
4
  <fieldset class="qube-segmented-field">
4
5
  <legend class="qube-visually-hidden"><%= field.label %></legend>
5
6
  <div class="<%= qube_classes(:segmented, "qube-segmented") %>">
6
7
  <% field.options.each do |option| %>
7
8
  <label class="<%= qube_classes(:segment, "qube-segment") %>">
8
9
  <%= tag.input(type: "radio", name: field.input_name, value: option.value, required: field.required,
10
+ checked: !field.value.nil? && field.value.to_s == option.value.to_s,
9
11
  disabled: field.disabled, class: "qube-segment-input qube-rows-input", data: field.data) %>
10
12
  <span><%= option.label %></span>
11
13
  </label>
@@ -1,4 +1,8 @@
1
- <%# Why a run failed or was cancelled (run_status.reason), then what to do about it (detail). %>
1
+ <%# Why a run failed or was cancelled (run_status.reason), then what to do about it (detail), or
2
+ what an ended run did (headline: QuBe Sync's sentence, shown as it is). %>
3
+ <% if run_status.headline %>
4
+ <p class="<%= qube_classes(:reason, "qube-run-headline") %>"><%= run_status.headline %></p>
5
+ <% end %>
2
6
  <% if run_status.reason %>
3
7
  <p class="<%= qube_classes(:reason, "qube-run-reason") %>"><%= run_status.reason %></p>
4
8
  <% end %>
@@ -1,11 +1,14 @@
1
- <%# A record's status (run_status, a QubeRails::RunStatusView): the error, then the summary, the
1
+ <%# A record's status (run_status, a QubeRails::RunStatusView): the summary, then the error, the
2
2
  failure's detail, why it waits on a stalled connection, and the buttons, or only the error
3
3
  before it's sent. %>
4
+ <% unless run_status.visible? %>
4
5
  <%= render "qube_rails/error", message: run_status.error %>
6
+ <% end %>
5
7
  <% if run_status.visible? %>
6
8
  <div class="<%= qube_classes(:status, run_status.css_class) %>" data-qube-sync-status="<%= run_status.status %>"<% if run_status.stall %> data-qube-stall="<%= run_status.stall %>"<% end %>>
7
9
  <%= render "qube_rails/run_status/summary", run_status: run_status %>
8
- <% if run_status.reason || run_status.detail %>
10
+ <%= render "qube_rails/error", message: run_status.error %>
11
+ <% if run_status.reason || run_status.detail || run_status.headline %>
9
12
  <%= render "qube_rails/run_status/detail", run_status: run_status %>
10
13
  <% end %>
11
14
  <% if run_status.stall %>
@@ -23,9 +23,6 @@
23
23
  <% end %>
24
24
  </fieldset>
25
25
  </header>
26
- <% if flash[:qube_rails_storyboard] %>
27
- <p class="qube-storyboard-notice" role="status"><%= flash[:qube_rails_storyboard] %></p>
28
- <% end %>
29
26
  <div class="qube-storyboard-body">
30
27
  <nav class="qube-storyboard-nav" aria-label="Screens">
31
28
  <% QubeRails::Storyboard.screens.group_by(&:group).each do |group, screens| %>
@@ -68,6 +65,10 @@
68
65
  question: QubeRails::Storyboard.question_view(screen, answer, qube_rails.storyboard_search_path(screen.key)) %>
69
66
  <% end %>
70
67
  </div>
68
+ <% if single && flash[:qube_rails_storyboard] %>
69
+ <%# Under the question, where the answer was given, so it's seen. %>
70
+ <p class="qube-storyboard-notice" role="status"><%= flash[:qube_rails_storyboard] %></p>
71
+ <% end %>
71
72
  <% if screen.partials.any? %>
72
73
  <details class="qube-storyboard-files">
73
74
  <summary>Override files (<%= screen.partials.size %>)</summary>
@@ -8,7 +8,9 @@ en:
8
8
  added: "Added to QuickBooks"
9
9
  done: "Done"
10
10
  done_with: "Done: %{outcome}"
11
+ done_with_errors: "Done, but some didn't go through"
11
12
  failed: "Couldn't sync"
13
+ realtime_required: "This company file's connection needs an upgrade to realtime before this can sync."
12
14
  not_started: "it couldn't be sent"
13
15
  cancelled: "Cancelled"
14
16
  cancel_reason: "it was stopped before it finished"
@@ -16,6 +18,7 @@ en:
16
18
  starting: "Sending to QuickBooks"
17
19
  unconfirmed: "Still waiting for QuickBooks"
18
20
  running: "Syncing with QuickBooks"
21
+ cancelling: "Cancelling…"
19
22
  quiet: "No update from QuickBooks for a while."
20
23
  check_for_updates: "Check for updates"
21
24
  try_again: "Try sending again"
@@ -24,6 +27,9 @@ en:
24
27
  not_checking_in: "QuickBooks hasn't checked in for a while, so this is waiting. Make sure the computer with QuickBooks is on and the Web Connector is running."
25
28
  quickbooks_unavailable: "The Web Connector is checking in but can't open QuickBooks. Open the company file in QuickBooks on that computer."
26
29
  other: "Syncing with QuickBooks has stopped for now. Check the computer with QuickBooks and its Web Connector."
30
+ connection:
31
+ set_up_again: "Set up QuickBooks again"
32
+ use_different_company_file: "Use a different company file"
27
33
  errors:
28
34
  not_starting: "This was already sent, so there's nothing to try again."
29
35
  not_quiet: "This was updated recently. Check again in a few minutes."
@@ -35,12 +41,35 @@ en:
35
41
  question_changed: "This question changed after the page loaded, so your answer wasn't sent. The page now shows the latest."
36
42
  answer_refused: "That answer couldn't be used. Check it and try again."
37
43
  answer_refused_with: "That answer couldn't be used: %{detail}"
44
+ question_moved_on: "This question was already answered or has changed, so your answer wasn't sent. If QuickBooks needs anything else, it will ask here."
38
45
  question:
39
46
  set_all: "Set all to:"
40
47
  use_pick: "Use this one"
41
- use_for_all: "Use for all %{count}"
48
+ # none_of_these and back_to_offered are unused since offered records and their search show
49
+ # at once; they go when qube_sync's Phoenix package drops its copies.
50
+ none_of_these:
51
+ one: "Not this one"
52
+ other: "None of these"
53
+ back_to_offered:
54
+ one: "← Back to the possible match"
55
+ other: "← Back to the %{count} possible matches"
56
+ choose: "Choose…"
57
+ optional: "(optional)"
58
+ needs_script: "Answering this needs JavaScript. Turn it on for this page, or answer from a browser that has it."
59
+ use_for_all:
60
+ one: "Use for the other record too"
61
+ other: "Use for the other %{count} records too"
62
+ used_for_all:
63
+ one: "Also filled in on the other record."
64
+ other: "Also filled in on the other %{count} records."
65
+ search_changed: "This question has changed. Reload the page to see the latest."
66
+ step: "%{position} of %{count}"
67
+ back: "Back"
68
+ next: "Next"
42
69
  or: "or"
43
70
  pick_a_match: "Pick one of the matches."
44
71
  no_matches: "No matches"
45
72
  searching: "Searching…"
46
73
  search_failed: "Search isn't available right now. Try again in a moment."
74
+ disclose_choice: "or %{label}…"
75
+ search_quickbooks: "Search QuickBooks…"
data/config/routes.rb CHANGED
@@ -6,6 +6,8 @@ QubeRails::Engine.routes.draw do
6
6
  # come back to your app: it tells the connection by webhook.
7
7
  post "quickbooks/connections", to: "connections#create", as: :connections
8
8
  post "quickbooks/connections/:id/onboarding", to: "connections#onboarding", as: :connection_onboarding
9
+ # Its "Use a different company file": QuBe Sync's page for switching it to another file.
10
+ post "quickbooks/connections/:id/company_file", to: "connections#company_file", as: :connection_company_file
9
11
  delete "quickbooks/connections/:id", to: "connections#destroy", as: :connection
10
12
 
11
13
  # Each run's webhook URL is QUBE_WEBHOOK_URL/runs/<run id> (QubeRails::Run#webhook_url), and a
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A connection's type ("realtime", "standard" or "simulated"), as onboarding made it and its events
4
+ # say since: Operation.start refuses a standard one before sending anything. Rows from 0.2.0 get
5
+ # "realtime", the default onboarding made then; the connection's next event corrects one that isn't.
6
+ # And a run's headline: its last event's sentence for a person, shown, never parsed.
7
+ class AddQubeConnectionTypeAndRunHeadline < ActiveRecord::Migration[5.2]
8
+ def change
9
+ add_column :qube_connections, :connection_type, :string, null: false, default: "realtime", limit: 20
10
+ add_column :qube_runs, :headline, :text
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ # For a connection switched to another company file (connection.company_file_changed): when it
4
+ # was, so runs from before it stop counting, and the revision of the change applied last; which
5
+ # QuickBooks links are the old file's until they're checked against the new one (stale_since),
6
+ # which the new file doesn't have (missing_since: kept, unused, checked again on the next change),
7
+ # and which it has under another name (review_since, review_name: unused until the app decides).
8
+ class AddQubeCompanyFileChange < ActiveRecord::Migration[5.2]
9
+ def change
10
+ add_column :qube_connections, :company_file_changed_at, :datetime
11
+ add_column :qube_connections, :company_file_revision, :integer
12
+ add_column :qube_quickbooks_records, :stale_since, :datetime
13
+ add_column :qube_quickbooks_records, :missing_since, :datetime
14
+ add_column :qube_quickbooks_records, :review_since, :datetime
15
+ add_column :qube_quickbooks_records, :review_name, :string
16
+ end
17
+ end
@@ -1,7 +1,8 @@
1
1
  # What your app does when one of its customers' QuickBooks Desktop connections changes. The
2
2
  # qube_rails gem does the rest: it checks each event is this connection's and newer than the
3
3
  # last one applied, under the connection row's lock, and updates the row's status
4
- # ("connected", "setup_cancelled", "stalled") and stall_reason before your handler runs.
4
+ # ("connected", "setup_cancelled", "stalled", or "pending" while it's set up again) and
5
+ # stall_reason before your handler runs.
5
6
  #
6
7
  # connection is the QubeRails::Connection (one company file; an account can have several) and
7
8
  # owner the account that connected it. Start a run on it with
@@ -34,5 +35,20 @@ module QuickbooksDesktop
34
35
  def resumed(event)
35
36
  log_event(event)
36
37
  end
38
+
39
+ # They chose "Use a different company file": the gem keeps this connection's QuickBooks links
40
+ # stale (unused) and checks them once it's connected. Set aside ids you keep yourself, and ask
41
+ # them to finish the setup.
42
+ def company_file_changed(event)
43
+ log_event(event)
44
+ end
45
+
46
+ # A batch of stale links of kind was looked up on the new file: relinked found with the same name
47
+ # (kept); review found under another name (ask the customer, then connection.confirm_link or
48
+ # reject_link each); missing not found (review a missing transaction before sending it again).
49
+ # stale_left is 0 once every check is done.
50
+ def links_checked(kind:, found:, relinked:, review:, missing:, stale_left:)
51
+ super
52
+ end
37
53
  end
38
54
  end
@@ -48,8 +48,10 @@ QubeRails.configure do |config|
48
48
  # until set.
49
49
  # config.prune_runs_after = 90.days
50
50
 
51
- # Onboarding makes realtime connections: workflows run only on those (billed as realtime).
51
+ # The type Connect makes connections as: "realtime" (workflows run only on those, billed as
52
+ # realtime) or "standard" (for an app that only queues requests). Connect's type param overrides it.
52
53
  # config.connection_type = "realtime"
54
+
53
55
  # How many times QubeRails::WebhookJob runs a delivery whose work raised, with a growing wait,
54
56
  # before it logs an error and raises to your adapter. With Sidekiq, whose own retries follow,
55
57
  # a smaller number (or 1, to leave retries to Sidekiq) avoids retrying twice over.
@@ -61,9 +63,15 @@ QubeRails.configure do |config|
61
63
  # config.dedupe = QubeRails::CacheDedupe.new(Rails.cache, expires_in: 1.day)
62
64
 
63
65
  # Your CSS framework's classes for the engine's screens, by piece, added beside their qube-
64
- # classes (pieces: QubeRails::Configuration::UI_PIECES; see the README's "Styling"):
65
- # config.ui_classes = { button: "btn btn-primary", button_secondary: "btn btn-link",
66
- # input: "form-control", select: "form-select", label: "form-label" }
66
+ # classes (pieces: QubeRails::Configuration::UI_PIECES; see the README's "Styling"). Tailwind:
67
+ # config.ui_classes = {
68
+ # button: "rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white hover:bg-indigo-500",
69
+ # button_secondary: "rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50",
70
+ # input: "rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-indigo-600 focus:outline-none",
71
+ # select: "rounded-md border border-gray-300 px-3 py-2 text-sm",
72
+ # label: "text-sm font-medium text-gray-900",
73
+ # error: "rounded-md bg-red-50 px-3 py-2 text-sm text-red-700"
74
+ # }
67
75
 
68
76
  # GET /qube/storyboard: every screen with sample data, in your layout. On in development.
69
77
  # config.storyboard = Rails.env.development?