Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inform add assets [INTEGRALCS-11927] #235

Open
wants to merge 69 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
35764d6
changed it for the bootstrap
Mar 19, 2014
8043919
Removed saveFormButton, added Signature element
tristankenney Mar 22, 2014
b8d5ec9
Various changes
tristankenney Apr 14, 2014
d58e829
Bug fixes
tristankenney Apr 22, 2014
0844a40
POWER TIME
tristankenney Apr 30, 2014
c421a9b
Merge branch 'master' of github.com:crusepartnership/formbuilder
tristankenney Apr 30, 2014
d4c3c1b
Grid element + info element + icon prefix
tristankenney May 23, 2014
6f2e323
Children can be rendered in flat structure
tristankenney May 26, 2014
78e6fd1
Bug and styling fixes
tristankenney May 27, 2014
6c87744
'options per row' and fixes
tristankenney Jul 24, 2014
cd641b0
WIP
tristankenney Nov 27, 2014
5be27be
That'll do pig
tristankenney Nov 29, 2014
ee82a3a
Now with table and datasource
tristankenney Apr 14, 2015
47c83ba
Updated to summernote 0.6.16 and added link item to info element
Aug 31, 2015
b16f25c
Update for info field + set version for karma
Aug 31, 2015
9abe8f1
Removed multiple from datasource
tristankenney Sep 29, 2015
c6a9af8
Merge branch 'master' of github.com:crusepartnership/formbuilder
tristankenney Sep 30, 2015
493fdb4
Added option to grid element (first row headings)
Oct 14, 2015
8615a03
Merge remote-tracking branch 'origin/master'
Oct 14, 2015
150b73c
Updated .gitignore
tristankenney Oct 15, 2015
70e581c
Added ability to set heading colours for elements in tables [INTEGRAL…
Dec 3, 2015
870c31c
Merge remote-tracking branch 'origin/master'
Dec 3, 2015
74d33ec
Updates for ability to set heading colours for elements in tables [IN…
Dec 8, 2015
3a4580e
INTEGRALCS-3790 INTEGRALCS-3791 Inform Element Improvements
Dec 22, 2015
7ea36ab
Updated default time label
tristankenney Jan 3, 2016
f22ea40
fix the issue for dulication feature INTEGRALCS-3961
Mar 8, 2016
68035e6
Added conditional question
tristankenney Apr 19, 2017
fd7857f
Updated styling + conditional options
tristankenney Apr 23, 2017
221d5c4
Added styling to paarent
tristankenney Apr 23, 2017
026c56d
Fixed issues with issues repeatedly being registered
tristankenney Apr 25, 2017
b16649f
Added tooltip init code
tristankenney Apr 25, 2017
aa62cbe
Added toggle to conditional functionality
tristankenney Apr 26, 2017
d406bca
Added condtional display to section element
tristankenney May 6, 2017
6b5bde6
Added padding to bottom of the formbuilder
tristankenney May 11, 2017
d4592e3
Merge pull request #1 from crusepartnership/padding-fix
tristankenney May 11, 2017
7c9c778
Rebuilt and merged with master
tristankenney May 11, 2017
1910483
Uncommented table
tristankenney May 11, 2017
d8d6895
Merge pull request #2 from crusepartnership/conditional-functionality
tristankenney May 11, 2017
7fd605d
Add get geolocation button
lukeluluke May 12, 2017
d61e12b
add label and descrption for Geolocation element
lukeluluke May 16, 2017
2c6e0c7
change name of geolocation element type to lower case
lukeluluke May 16, 2017
d5bf05a
Add Reference ID to formbuilder field, and show reference id in Condi…
lukeluluke Aug 10, 2017
0713367
Merge pull request #3 from crusepartnership/add_geolocation
tristankenney Aug 10, 2017
24db0f8
Move Reference ID to end of header [INTEGRALCS-5847]
lukeluluke Aug 10, 2017
a143f40
Merge remote-tracking branch 'origin/master' into element-add-referen…
tristankenney Aug 17, 2017
6d0c899
fix for conditional functionality parent child question [INTEGRALCS-5…
Aug 28, 2017
74ccaab
Merge pull request #6 from crusepartnership/conditional-functionality…
tristankenney Aug 29, 2017
cc0452e
Merge pull request #4 from crusepartnership/element-add-referenceId
tristankenney Aug 29, 2017
695df50
Rebuilt post-merge
tristankenney Aug 29, 2017
00dc0c9
fix the issue for conditional display [SUPPORT-778] (#9)
raycui2011 Dec 20, 2017
e1daab5
fix the issue for element can not be removed in the table [SUPPORT-84…
raycui2011 Jan 5, 2018
f2fc899
use global variable to store the element for index[INTEGRALCS-6231]
Jan 24, 2018
7e57962
fix typo [INTEGRALCS-6231]
Jan 24, 2018
6f1b7a9
FormBuilder performance improvements
Jan 24, 2018
07901d3
Add HTML stripping (#14)
chintogtokh Nov 2, 2018
c7d06c1
Fix for formbuilder index issue
raycui2011 Dec 3, 2018
157bb62
Merge pull request #17 from crusepartnership/formbuilder-wrapper-inde…
Dec 3, 2018
34dc63e
Add fixes to correctly convert slash n to br [INTEGRALCS-8877]
chintogtokh Jan 30, 2019
4da6a39
Merge pull request #18 from crusepartnership/integralcs-8877-nl2br
lukeluluke Jan 30, 2019
bac5003
Add minor fix
chintogtokh Jan 30, 2019
4076dd7
Re-add commit c7d06c1 fixes to dist and coffeescript
chintogtokh Feb 11, 2019
2b585f3
Fix issue with info element [INTEGRALCS-9842]
chintogtokh May 15, 2019
18777d2
Add comments/readme
chintogtokh May 16, 2019
6f82e76
Re-add foxes from CLIENTHUB-1748 to coffeescript [CLIENTHUB-1748]
chintogtokh May 16, 2019
b38f88d
Make info description print raw - note that this has to be handled se…
chintogtokh May 16, 2019
3454889
Revert index.html
chintogtokh May 17, 2019
2613ed2
Merge pull request #20 from crusepartnership/integralcs-9842-formbuilder
chintogtokh May 17, 2019
6ebf934
Make formbuilder runs on server [INTEGRALCS-10486]
lukeluluke Oct 4, 2019
07b1e7c
Make formbuilder runs on server [INTEGRALCS-10486]
lukeluluke Oct 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Now with table and datasource
tristankenney committed Apr 14, 2015
commit ee82a3ab10296ef85c6d1df5f2116b9f8652ce14
2 changes: 1 addition & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ module.exports = (grunt) ->
'bower_components/jquery-ui/ui/jquery.ui.droppable.js'
'bower_components/jquery-ui/ui/jquery.ui.sortable.js'
'bower_components/jquery.scrollWindowTo/index.js'
'bower_components/underscore/underscore-min.js'
'bower_components/lodash/dist/lodash.min.js'
'bower_components/underscore.mixin.deepExtend/index.js'
'bower_components/rivets/dist/rivets.js'
'bower_components/backbone/backbone.js'
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
"bootstrap": "~3.1.1",
"summernote": "~0.5.1",
"node-uuid": "~1.4.1",
"underscore": "~1.7.0",
"mathjs": "~1.1.1"
"mathjs": "~1.1.1",
"lodash": "~2.4.1"
}
}
}
35 changes: 18 additions & 17 deletions dist/formbuilder.css
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
.fb-icon-date:before{content:'\e800'}
.fb-icon-radio:before{content:'\e801'}
.fb-icon-checkbox:before{content:'\e802'}
.fb-icon-list:before{content:'\e803'}
.fb-icon-data-source:before{content:'\e803'}
.fb-icon-dropdown:before{content:'\e804'}
.fb-icon-signature:before{content:'\e805'}
.fb-icon-info:before{content:'\e806'}
@@ -42,6 +42,7 @@
.edit-response-field input,.edit-response-field textarea,.edit-response-field select{border:thin solid #ddd;border-radius:.25em;padding:.5em;display:inline-block;height:auto;vertical-align:middle}
.edit-response-field input:focus,.edit-response-field textarea:focus,.edit-response-field select:focus{outline:none}
.edit-response-field select{font-size:14px}
input[readonly]{cursor:not-allowed;background-color:#eee}
.fb-field-wrapper .subtemplate-wrapper{border:1px dashed transparent;margin-bottom:10px;padding:10px;position:relative}
.fb-field-wrapper .subtemplate-wrapper .cover{position:absolute;top:0;left:0;height:100%;width:100%;z-index:2}
.fb-field-wrapper .subtemplate-wrapper > label{display:block;border-bottom:thin solid #eee;padding-bottom:3px;margin-bottom:7px}
@@ -52,7 +53,6 @@
.fb-field-wrapper .input-line > span input{width:100%}
.fb-field-wrapper .input-line > span > label{display:block;font-size:13px;margin-left:3px}
.fb-field-wrapper .help-block{display:block;font-size:12px;margin-top:5px}
.fb-edit-field-grid .fb-label-description{display:none}
.fb-edit-field-wrapper{font-size:13px}
.fb-edit-field-wrapper .fb-field-label{font-weight:normal;background:#eee;padding:.75em;color:#666;font-size:1.25em}
.fb-edit-field-wrapper .fb-field-label .type{margin-top:.5em;display:block;font-family:'Source Sans Pro',sans-serif;font-size:1em}
@@ -85,6 +85,7 @@
.response-field-table .cover{display:none}
.response-field-table .section-name{display:inline-block}
.response-field-table .element-selector{margin:0 5px;float:right;position:absolute;right:5px;top:5px}
.response-field-table tr{vertical-align:top}
.response-field-table table{margin-bottom:30px}
.response-field-table table td{padding:10px 10px 0 10px}
.response-field-table table td label{border:none !important}
@@ -93,63 +94,63 @@
.fb-options-per-row-1:before{content:" ";display:table}
.fb-options-per-row-1:after{content:" ";display:table;clear:both}
.fb-options-per-row-1{clear:both}
.fb-options-per-row-1 .fb-option-wrapper{width:100%;float:left}
.fb-options-per-row-1 .fb-option-wrapper{width:100%}
.fb-options-per-row-2:before{content:" ";display:table}
.fb-options-per-row-2:after{content:" ";display:table;clear:both}
.fb-options-per-row-2{clear:both}
.fb-options-per-row-2 .fb-option-wrapper{width:50%;float:left}
.fb-options-per-row-2 .fb-option-wrapper{width:50%}
.fb-options-per-row-3:before{content:" ";display:table}
.fb-options-per-row-3:after{content:" ";display:table;clear:both}
.fb-options-per-row-3{clear:both}
.fb-options-per-row-3 .fb-option-wrapper{width:33.333333333333336%;float:left}
.fb-options-per-row-3 .fb-option-wrapper{width:33.333333333333336%}
.fb-options-per-row-4:before{content:" ";display:table}
.fb-options-per-row-4:after{content:" ";display:table;clear:both}
.fb-options-per-row-4{clear:both}
.fb-options-per-row-4 .fb-option-wrapper{width:25%;float:left}
.fb-options-per-row-4 .fb-option-wrapper{width:25%}
.fb-options-per-row-5:before{content:" ";display:table}
.fb-options-per-row-5:after{content:" ";display:table;clear:both}
.fb-options-per-row-5{clear:both}
.fb-options-per-row-5 .fb-option-wrapper{width:20%;float:left}
.fb-options-per-row-5 .fb-option-wrapper{width:20%}
.fb-options-per-row-6:before{content:" ";display:table}
.fb-options-per-row-6:after{content:" ";display:table;clear:both}
.fb-options-per-row-6{clear:both}
.fb-options-per-row-6 .fb-option-wrapper{width:16.666666666666668%;float:left}
.fb-options-per-row-6 .fb-option-wrapper{width:16.666666666666668%}
.fb-options-per-row-7:before{content:" ";display:table}
.fb-options-per-row-7:after{content:" ";display:table;clear:both}
.fb-options-per-row-7{clear:both}
.fb-options-per-row-7 .fb-option-wrapper{width:14.285714285714286%;float:left}
.fb-options-per-row-7 .fb-option-wrapper{width:14.285714285714286%}
.fb-options-per-row-8:before{content:" ";display:table}
.fb-options-per-row-8:after{content:" ";display:table;clear:both}
.fb-options-per-row-8{clear:both}
.fb-options-per-row-8 .fb-option-wrapper{width:12.5%;float:left}
.fb-options-per-row-8 .fb-option-wrapper{width:12.5%}
.fb-options-per-row-9:before{content:" ";display:table}
.fb-options-per-row-9:after{content:" ";display:table;clear:both}
.fb-options-per-row-9{clear:both}
.fb-options-per-row-9 .fb-option-wrapper{width:11.11111111111111%;float:left}
.fb-options-per-row-9 .fb-option-wrapper{width:11.11111111111111%}
.fb-options-per-row-10:before{content:" ";display:table}
.fb-options-per-row-10:after{content:" ";display:table;clear:both}
.fb-options-per-row-10{clear:both}
.fb-options-per-row-10 .fb-option-wrapper{width:10%;float:left}
.fb-options-per-row-10 .fb-option-wrapper{width:10%}
.fb-options-per-row-11:before{content:" ";display:table}
.fb-options-per-row-11:after{content:" ";display:table;clear:both}
.fb-options-per-row-11{clear:both}
.fb-options-per-row-11 .fb-option-wrapper{width:9.090909090909092%;float:left}
.fb-options-per-row-11 .fb-option-wrapper{width:9.090909090909092%}
.fb-options-per-row-12:before{content:" ";display:table}
.fb-options-per-row-12:after{content:" ";display:table;clear:both}
.fb-options-per-row-12{clear:both}
.fb-options-per-row-12 .fb-option-wrapper{width:8.333333333333334%;float:left}
.fb-options-per-row-12 .fb-option-wrapper{width:8.333333333333334%}
.fb-options-per-row-13:before{content:" ";display:table}
.fb-options-per-row-13:after{content:" ";display:table;clear:both}
.fb-options-per-row-13{clear:both}
.fb-options-per-row-13 .fb-option-wrapper{width:7.6923076923076925%;float:left}
.fb-options-per-row-13 .fb-option-wrapper{width:7.6923076923076925%}
.fb-options-per-row-14:before{content:" ";display:table}
.fb-options-per-row-14:after{content:" ";display:table;clear:both}
.fb-options-per-row-14{clear:both}
.fb-options-per-row-14 .fb-option-wrapper{width:7.142857142857143%;float:left}
.fb-options-per-row-14 .fb-option-wrapper{width:7.142857142857143%}
.fb-options-per-row-15:before{content:" ";display:table}
.fb-options-per-row-15:after{content:" ";display:table;clear:both}
.fb-options-per-row-15{clear:both}
.fb-options-per-row-15 .fb-option-wrapper{width:6.666666666666667%;float:left}
.fb-options-per-row-15 .fb-option-wrapper{width:6.666666666666667%}
.response-field-grid-table{border-collapse:collapse;border-spacing:0;margin-bottom:5px;table-layout:fixed;width:100%}
.response-field-grid-table .response-field-grid-row{height:100px;vertical-align:top}
.response-field-grid-table td{padding:10px 10px 0 10px}
623 changes: 490 additions & 133 deletions dist/formbuilder.js

Large diffs are not rendered by default.

75 changes: 60 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
@@ -30,18 +30,31 @@

<script>
$(function() {
Formbuilder.attr('sources', ['List 1', 'List 2']);
Formbuilder.attr('sources', {
Person: {
title:'Employee',
properties: {'id': 'ID', 'payroll_number': 'Payroll Number'}
},
Contractor: {
title:'Contractor',
properties: {'id': 'ID', 'name': 'Name'},
filters: {
status : {
name: 'Status',
values: {
'1': 'Draft',
'2': 'In Progress',
'3': 'Current',
'4': 'Blocked'
}
}

}
}
});
window.fb = new Formbuilder({
selector: '.fb-main',
bootstrapData: [
{
"label": "Employee Name",
"type": "text",
"required": true,
"options": {},
"parent_uuid": "909cbdba-4431-4ed8-ab28-96006d356ad7",
"uuid": "d2ce1858-603a-4e31-8cce-ea51ef08ef13"
},
{
"label": "Hours worked",
"type": "number",
@@ -66,20 +79,44 @@
"parent_uuid": "909cbdba-4431-4ed8-ab28-96006d356ad7",
"uuid": "c171bdb9-dffb-4bf7-84a9-fd6ae848dd79"
},
{
"label": "Total Column",
"type": "number",
"model_only": true,
"parent_uuid": "c171bdb9-dffb-4bf7-84a9-fd6ae848dd79",
"uuid": "b9a1b61f-fd1a-4df5-b8ba-9bed3aa41d7a",
"options": {
"calculation_type": "sum(column_uuid_c171bdb9_dffb_4bf7_84a9_fd6ae848dd79)"
}
},
{
"label": "Total Hours Worked",
"type": "number",
"model_only": true,
"parent_uuid": "76b257ed-16fa-422d-a732-da6c6170c807",
"uuid": "efc11190-a876-457a-9210-1d2ae8882ff5",
"options": {
"calculation_type": "sum(column_uuid_76b257ed_16fa_422d_a732_da6c6170c807)"
}
},
{
"type": "table",
"label": "Table",
"options": {
"elements": [{"uuid":"d2ce1858-603a-4e31-8cce-ea51ef08ef13"},{"uuid":"76b257ed-16fa-422d-a732-da6c6170c807", "totalColumn": true},{"uuid":"a720d44f-e4da-4fa5-a7aa-567e82a5fe2a"},{"uuid":"c171bdb9-dffb-4bf7-84a9-fd6ae848dd79", "totalColumn": true}],
"elements": [{"uuid":"d2ce1858-603a-4e31-8cce-ea51ef08ef13"},{"uuid":"76b257ed-16fa-422d-a732-da6c6170c807", "totalColumn": true, "totalColumnUuid": 'efc11190-a876-457a-9210-1d2ae8882ff5'},{"uuid":"a720d44f-e4da-4fa5-a7aa-567e82a5fe2a"},{"uuid":"c171bdb9-dffb-4bf7-84a9-fd6ae848dd79", "totalColumn": true, "totalColumnUuid": 'b9a1b61f-fd1a-4df5-b8ba-9bed3aa41d7a'}],
},
"uuid": "909cbdba-4431-4ed8-ab28-96006d356ad7"
},
{
"type": "list",
"label": "List",
"type": "datasource",
"label": "Work Contractor",
"options": {
"data_source": 'List 2',
"multiple_selections": true
"data_source": 'Contractor',
"value_template": 'name',
"multiple_selections": true,
"is_filtered": true,
"filter": "Status",
"filter_values": [1, 2]

},
"uuid": "188e4f03-4d5d-4234-9b1f-f916fee48691"
@@ -171,6 +208,14 @@
"parent_uuid": '940cb41b-8440-4ff2-b699-a1dfa6cccebb',
"uuid": "097fae5e-90ce-4f4e-bed5-7e86eb86a913"
},
{
"label": "Employee Name",
"type": "text",
"required": true,
"options": {},
"parent_uuid": "909cbdba-4431-4ed8-ab28-96006d356ad7",
"uuid": "d2ce1858-603a-4e31-8cce-ea51ef08ef13"
},
{
"type": "radio",
"answers": [{
@@ -186,7 +231,7 @@
},
"parent_uuid": '940cb41b-8440-4ff2-b699-a1dfa6cccebb',
"uuid": "ff9f46f8-bb47-4211-b690-d884285feaf9"
},
}

]
});
2 changes: 2 additions & 0 deletions src/scripts/fields/checkbox.coffee
Original file line number Diff line number Diff line change
@@ -38,10 +38,12 @@ Formbuilder.registerField 'checkbox',

defaultAttributes: (attrs) ->
attrs.answers = [
uuid: uuid.v4()
label: "",
checked: false,
score: false
,
uuid: uuid.v4()
label: "",
checked: false,
score: false
74 changes: 74 additions & 0 deletions src/scripts/fields/datasource.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
Formbuilder.registerField 'datasource',

name: 'List'

order: 70

view: """
<select>
<option>
<%= rf.source().title %>
(<%= rf.sourceProperty(rf.get(Formbuilder.options.mappings.DATA_SOURCE.VALUE_TEMPLATE)) %>)
</option>
</select>
"""

edit: """
<%= Formbuilder.templates['edit/data_source_options']({ rf: rf }) %>
"""

addButton: """
<span class="fb-icon-data-source"></span> Data Source
"""

defaultAttributes: (attrs, formbuilder) ->
attrs.initialize = () ->

@on "change", (model) ->
if _.nested(model, 'changed.options.data_source') != undefined
sourceProperties = _.keys(model.sourceProperties())
model.set('options.required_properties', sourceProperties)
valueTemplate = _.first(sourceProperties)
model.set('options.value_template', valueTemplate)

@on "destroy", (model) ->
@collection.each (collectionModel) ->
if collectionModel.get('options.populate_uuid') is model.get('uuid')
collectionModel.set('options.populate_uuid', null)
collectionModel.set('options.populate_from', null)



attrs.source = () ->
source = if @options then @options.data_source else @get(Formbuilder.options.mappings.DATA_SOURCE.DATA_SOURCE)
sources = formbuilder.attr('sources')
_.nested(sources, source) || null

attrs.sourceProperties = () ->
source = @source()
_.nested(source, 'properties') || []

attrs.filters = () ->
source = @source()
_.nested(source, 'filters') || null

attrs.currentFilter = () ->
source = @source()
_.nested(source, 'filters.' + @get('options.filter')) || {}

attrs.filterValues = () ->
@currentFilter().values || {}



attrs.sourceProperty = (property) ->
@sourceProperties()[property] || null

attrs.options.multiple_selections = false
attrs.options.is_filtered = false
attrs.options.data_source = attrs.source() || _.keys(formbuilder.attr('sources') || {})[0];
attrs.options.required_properties = _.keys(attrs.sourceProperties(attrs.options.data_source))
attrs.options.filter = attrs.filters()
attrs.options.filter_values = []
attrs.options.value_template = _.first(attrs.options.required_properties)
attrs
2 changes: 2 additions & 0 deletions src/scripts/fields/dropdown.coffee
Original file line number Diff line number Diff line change
@@ -28,10 +28,12 @@ Formbuilder.registerField 'dropdown',

defaultAttributes: (attrs) ->
attrs.answers = [
uuid: uuid.v4()
label: "",
checked: false,
score: ""
,
uuid: uuid.v4()
label: "",
checked: false,
score: ""
26 changes: 0 additions & 26 deletions src/scripts/fields/list.coffee

This file was deleted.

11 changes: 7 additions & 4 deletions src/scripts/fields/number.coffee
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ Formbuilder.registerField 'number',
order: 30

view: """
<input type='text' class="calculated" value="<%= rf.get(Formbuilder.options.mappings.NUMERIC.CALCULATION_DISPLAY) %>" />
<input type='text' class="calculated" value="<%= rf.get(Formbuilder.options.mappings.NUMERIC.CALCULATION_DISPLAY) %>" <%= rf.get(Formbuilder.options.mappings.NUMERIC.CALCULATION_DISPLAY) ? 'readonly="readonly"' : '' %> />
<% if (units = rf.get(Formbuilder.options.mappings.UNITS)) { %>
<%= units %>
<% } %>
@@ -27,8 +27,9 @@ Formbuilder.registerField 'number',
attrs.options.total_sequence = false

attrs.insertion = () ->
if @parentModel()
totalColumn = @parentModel().totalColumn @get('uuid')
parentModel = @parentModel()
if parentModel and parentModel.get('type') == 'table'
totalColumn = parentModel.totalColumn @get('uuid')
@attributes.options.total_sequence = totalColumn

attrs.initialize = () ->
@@ -40,6 +41,7 @@ Formbuilder.registerField 'number',
if _.nested(model, 'changed.options.total_sequence') != undefined
totalSequence = _.nested model, 'changed.options.total_sequence'
@parentModel().totalColumn model.get('uuid'), totalSequence
model

attrs.numericSiblings = () ->
parentModel = @parentModel()
@@ -55,7 +57,8 @@ Formbuilder.registerField 'number',
if calculation_type != ''
operator = if calculation_type is 'SUM' then '+' else '*'
numericSiblings = @numericSiblings()
@set('options.calculation_expression', _.map(numericSiblings, (model) -> model.get('uuid')).join(operator))
#Prefix with uuid_ and underscore '-' to prevent illegal identifiers
@set('options.calculation_expression', _.map(numericSiblings, (model) -> 'uuid_' + model.get('uuid').replace(/-/g, '_')).join(operator))
@set('options.calculation_display', '= ' + _.map(numericSiblings, (model) -> model.get('label')).join(operator))
console.log(@get('options.calculation_expression'))
else
2 changes: 2 additions & 0 deletions src/scripts/fields/radio.coffee
Original file line number Diff line number Diff line change
@@ -42,10 +42,12 @@ Formbuilder.registerField 'radio',
defaultAttributes: (attrs) ->
# @todo
attrs.answers = [
uuid: uuid.v4()
label: "",
checked: false,
score: ""
,
uuid: uuid.v4()
label: "",
checked: false,
score: ""
39 changes: 38 additions & 1 deletion src/scripts/fields/table.coffee
Original file line number Diff line number Diff line change
@@ -20,6 +20,9 @@ Formbuilder.registerField 'table',
</div>
<div class='fb-clear'></div>
</div>
<label class="checkbox">
<input type='checkbox' data-rv-checked='model.<%= Formbuilder.options.mappings.GRID.FULL_WIDTH %>' /> Display full width ?
</label>
"""

addButton: """
@@ -28,6 +31,15 @@ Formbuilder.registerField 'table',

defaultAttributes: (attrs) ->
attrs.options.full_width = false
attrs.initialize = () ->
parent = @
_.each @childModels, (childModel) ->
childModel.on "change", (model) ->
if _.nested(model, 'changed.options.column_width') != undefined
parent.columnWidth(model.get('uuid'), model.get('options.column_width'))
model


attrs.childModels = () ->
elementsUuids = _.pluck @get('options.elements'), 'uuid'
@collection.filter (model) ->
@@ -37,14 +49,39 @@ Formbuilder.registerField 'table',
attrs.elementOptions = (elementUuid) ->
_.findWhere @get('options.elements'), {uuid:elementUuid}


attrs.createTotalColumnModel = (parentUuid) ->
totalColumnModel = new FormbuilderModel(Formbuilder.helpers.defaultFieldAttrs('number'))
totalColumnModel.set('options.calculation_expression', 'sum(column_uuid_' + parentUuid.replace(/-/g, '_') + ')')
totalColumnModel.set('model_only', true)
totalColumnModel.set('parent_uuid', parentUuid)
@collection.add totalColumnModel
totalColumnModel

attrs.columnWidth = (elementUuid, width) ->
elements = @get('options.elements')
_.each elements, (element, index) ->
if element.uuid is elementUuid
elements[index].columnWidth = width
,@

attrs.totalColumn = (elementUuid, value) ->
elements = @get('options.elements')
if value != undefined
_.each elements, (element, index) ->
if element.uuid is elementUuid
if element.totalColumnUuid is undefined
totalColumnModel = @createTotalColumnModel(element.uuid)
elements[index].totalColumnUuid = totalColumnModel.get('uuid')
elements[index].totalColumn = value
, @

@set 'options.elements', elements
else
@elementOptions(elementUuid).totalColumn || false
if @elementOptions(elementUuid)
@elementOptions(elementUuid).totalColumn || false
else
false


attrs
4 changes: 3 additions & 1 deletion src/scripts/fields/text.coffee
Original file line number Diff line number Diff line change
@@ -8,7 +8,9 @@ Formbuilder.registerField 'text',
<input type='text' class='rf-size-<%= rf.get(Formbuilder.options.mappings.SIZE) %>' />
"""

edit: ""
edit: """
<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>
"""

addButton: """
<span class="fb-icon-text"></span> Text
4 changes: 3 additions & 1 deletion src/scripts/fields/textarea.coffee
Original file line number Diff line number Diff line change
@@ -8,7 +8,9 @@ Formbuilder.registerField 'textarea',
<textarea class='rf-size-<%= rf.get(Formbuilder.options.mappings.SIZE) %>'></textarea>
"""

edit: ""
edit: """
<%= Formbuilder.templates['edit/populate_from']({ rf: rf }) %>
"""

addButton: """
<span class="fb-icon-textarea"></span> Paragraph
218 changes: 151 additions & 67 deletions src/scripts/main.coffee

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/scripts/rivets-config.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
rivets.binders.append =
routine: (el, value) ->
el.checked = _.find(value, (item) -> String(item) == String(el.value)) != undefined
bind: (el) ->

@callback = () =>
currentValue = _.clone(@model.get(@keypath)) || []
if el.value and _.contains(currentValue, el.value)
newValue = _.without(currentValue, el.value)
@model.set(@keypath, currentValue)
else
currentValue.push(el.value)
@model.set(@keypath, currentValue)
$(el).on('change', @callback)
unbind: (el) ->
$(el).off('change', @callback)


rivets.formatters.length = (value) ->
if value then value.length else 0


rivets.binders.input =
publishes: true
routine: rivets.binders.value.routine
19 changes: 10 additions & 9 deletions src/styles/formbuilder.styl
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ $editing-border = darken($editing-bg, 7%)
.fb-icon-date:before { content: '\e800'; } /* '' */
.fb-icon-radio:before { content: '\e801'; } /* '' */
.fb-icon-checkbox:before { content: '\e802'; } /* '' */
.fb-icon-list:before { content: '\e803'; } /* '' */
.fb-icon-data-source:before { content: '\e803'; } /* '' */
.fb-icon-dropdown:before { content: '\e804'; } /* '' */
.fb-icon-signature:before { content: '\e805'; } /* '' */
.fb-icon-info:before { content: '\e806'; } /* '' */
@@ -229,6 +229,11 @@ $editing-border = darken($editing-bg, 7%)
}
}

input[readonly] {
cursor: not-allowed;
background-color: #eeeeee;
}


.fb-field-wrapper .subtemplate-wrapper {
border: 1px dashed transparent;
@@ -287,13 +292,6 @@ $editing-border = darken($editing-bg, 7%)
margin-top: 5px;
}

.fb-edit-field-grid {
.fb-label-description
{
display: none;
}
}

.fb-edit-field-wrapper {
font-size: 13px;
}
@@ -447,6 +445,10 @@ $editing-border = darken($editing-bg, 7%)
top: 5px;
}

tr {
vertical-align: top;
}



table {
@@ -481,7 +483,6 @@ for row in (1..15)
clear both
.fb-option-wrapper
width (100% / row)
float left



1 change: 1 addition & 0 deletions src/templates/edit/base.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%= Formbuilder.templates['edit/base_header']({rf: rf}) %>
<%= Formbuilder.templates['edit/common']({rf: rf}) %>
<%= Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].edit({rf: rf}) %>
<%= Formbuilder.templates['edit/columnwidth']({rf: rf}) %>
6 changes: 6 additions & 0 deletions src/templates/edit/columnwidth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!-- <div class='fb-edit-section-header'>Column width</div>
Width in px
<input class="form-control" type="number" data-rv-input="model.<%= Formbuilder.options.mappings.COLUMN_WIDTH %>" style="width: 50px" />
-->
2 changes: 1 addition & 1 deletion src/templates/edit/common.html
Original file line number Diff line number Diff line change
@@ -8,4 +8,4 @@
<%= Formbuilder.templates['edit/checkboxes']() %>
</div>
<div class='fb-clear'></div>
</div>
</div>
47 changes: 47 additions & 0 deletions src/templates/edit/data_source_options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<label class="checkbox">
<input type='checkbox' data-rv-checked='model.<%= Formbuilder.options.mappings.DATA_SOURCE.MULTIPLE %>' />
Multiple selections
</label>

<div class='fb-edit-section-header'>Data Source</div>
<select data-rv-value="model.<%= Formbuilder.options.mappings.DATA_SOURCE.DATA_SOURCE %>">
<% for (i in (Formbuilder.attr('sources') || [])) { %>
<option value="<%= i %>">
<%= Formbuilder.attr('sources')[i].title %>
</option>
<% } %>
</select>
<div class='fb-edit-section-header'>Display</div>
<select data-rv-value="model.<%= Formbuilder.options.mappings.DATA_SOURCE.VALUE_TEMPLATE %>">
<%
for (i in (rf.sourceProperties() || [])) { %>
<option value="<%= i %>">
<%= rf.sourceProperties()[i] %>
</option>
<% } %>
</select>
<% if (rf.filters()) { %>
<div class='fb-edit-section-header'> Filter </div>
<label class="checkbox">
<input type='checkbox' class="js-scoring" data-rv-checked='model.<%= Formbuilder.options.mappings.DATA_SOURCE.IS_FILTERED %>' />
Apply a filter?
</label>
<% if (rf.get(Formbuilder.options.mappings.DATA_SOURCE.IS_FILTERED)) { %>
<select data-rv-value="model.<%= Formbuilder.options.mappings.DATA_SOURCE.FILTER %>">
<option value="null">[ No Filter ]</option>
<%
for (i in (rf.filters() || [])) { %>
<option value="<%= i %>">
<%= rf.filters()[i].name %>
</option>
<% } %>
</select>
<%
for (i in rf.filterValues()) { %>
<label class="checkbox">
<input type='checkbox' data-rv-append='model.<%= Formbuilder.options.mappings.DATA_SOURCE.FILTER_VALUES %>' value="<%= i %>" />
<%= rf.filterValues()[i] %>
</label>
<% } %>
<% } %>
<% } %>
14 changes: 0 additions & 14 deletions src/templates/edit/list_options.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/templates/edit/options.html
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
<% } %>

<div class='option' data-rv-each-option='model.<%= Formbuilder.options.mappings.OPTIONS %>'>
<input type="checkbox" class='js-default-updated' data-rv-checked="option:checked" />
<!-- <input type="checkbox" class='js-default-updated' data-rv-checked="option:checked" /> -->
<input type="text" data-rv-input="option:label" placeholder="Label" class='option-label-input' />
<% if (rf.get(Formbuilder.options.mappings.INCLUDE_SCORING)) { %>
<input type="text" data-rv-input="option:score" placeholder="Score" class='option-score-input' />
28 changes: 28 additions & 0 deletions src/templates/edit/populate_from.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<% var list = rf.collection.findDataSourceFields();
if (list.length) { %>
<div class='fb-edit-section-header'>Populate From</div>
<select data-rv-value="model.<%= Formbuilder.options.mappings.POPULATE_UUID %>">
<option>
<%
for (i in (list || [])) { %>
<option value="<%= list[i].get('uuid') %>">
<%= list[i].get('label') %>
</option>
<% } %>
</select>
<select data-rv-value="model.<%= Formbuilder.options.mappings.POPULATE_FROM %>">
<option>
<%
var populationUuid = rf.get('options.populate_uuid');
var populationModel = rf.collection.findWhereUuid(populationUuid) || {};
if (populationUuid && populationModel) {
var dataSource = populationModel.get('options.data_source');
var listProperties = Formbuilder.attr('sources')[dataSource].properties;
for (i in listProperties) { %>
<option value="<%= i %>">
<%= listProperties[i] %>
</option>
<% }
} %>
</select>
<% } %>
1 change: 0 additions & 1 deletion src/templates/view/table_element.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<%= Formbuilder.fields[rf.get(Formbuilder.options.mappings.TYPE)].view({rf: rf}) %>
<%= Formbuilder.templates['view/description']({rf: rf}) %>
<%= Formbuilder.templates['view/remove']({rf: rf}) %>
8 changes: 4 additions & 4 deletions src/templates/view/table_field.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<span class="drop-area" rowspan="2">
<span class="drop-area">
<%= Formbuilder.templates['view/element_selector']() %>
</span>
<table class="response-field-table">

<tbody>
<tr>
<% for (i in (rf.get('options.elements') || [])) { %>
<td data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper header header-<%= rf.get('options.elements')[i].uuid %>"></td>
<td width="<%= rf.get('options.elements')[i].width %>" data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper header header-<%= rf.get('options.elements')[i].uuid %>"></td>
<% } %>
</tr>
<tr>
<% for (i in (rf.get('options.elements') || [])) { %>
<td data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper element element-<%= rf.get('options.elements')[i].uuid %>"></td>
<td width="<%= rf.get('options.elements')[i].width %>" data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper element element-<%= rf.get('options.elements')[i].uuid %>"></td>
<% } %>
</tr>
</tbody>
<tfoot>
<tr>
<% for (i in (rf.get('options.elements') || [])) { %>
<td data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper total total-<%= rf.get('options.elements')[i].uuid %>"></td>
<td width="<%= rf.get('options.elements')[i].width %>" data-uuid="<%= rf.get('options.elements')[i].uuid %>" class="fb-field-wrapper subtemplate-wrapper total total-<%= rf.get('options.elements')[i].uuid %>"></td>
<% } %>
</tr>
</tfoot>
3 changes: 2 additions & 1 deletion src/templates/view/table_header.html
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%= Formbuilder.templates['view/label']({rf: rf}) %>
<%= Formbuilder.templates['view/label']({rf: rf}) %>
<%= Formbuilder.templates['view/description']({rf: rf}) %>
62 changes: 56 additions & 6 deletions vendor/js/vendor.js

Large diffs are not rendered by default.