-
Notifications
You must be signed in to change notification settings - Fork 148
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
enhance: form builder blank form, form field icons #1506
Open
sapayth
wants to merge
58
commits into
weDevsOfficial:develop
Choose a base branch
from
sapayth:enhance/form_builder_blank_form
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
63151b3
initial header style
sapayth 787c082
preview and save buttons
sapayth a7c5fe7
dropdown effect enhanced
sapayth d008e8a
shortcode copy icon enhanced
sapayth c96afbf
backward compatibility added for old wpuf pro
sapayth 065b1fa
update copy shortcode icon
sapayth 6607241
Merge branch 'develop' into enhance/header_for_form_builder_ui_redesign
sapayth ab3ce2c
type and image fixing
sapayth 3eba5a0
Merge remote-tracking branch 'upstream/develop' into enhance/header_f…
sapayth 7293f64
updated form builder header design
sapayth fe34c3b
nav css
sapayth ab36c5c
Squashed commit of the following:
sapayth 6a93fc4
Merge remote-tracking branch 'upstream/develop' into enhance/new_buil…
sapayth dbef1af
initial design
sapayth ab32ffd
hidden fields and other small css
sapayth ed4b378
column field
sapayth d02c221
Merge remote-tracking branch 'upstream/develop' into enhance/new_buil…
sapayth bc50028
Merge remote-tracking branch 'upstream/develop' into enhance/new_buil…
sapayth 3b59cbc
column fields initial rendering
sapayth 4443867
column field initial
sapayth aa1c0d8
fix action buttons move action
sapayth aa9f072
icon for featured image
sapayth 21d19c2
icon for image upload button
sapayth 87f577d
Merge remote-tracking branch 'upstream/develop' into enhance/new_buil…
sapayth ac5db7e
backward compatibility for pro version
sapayth 3df5eeb
compatibility for settings and notification tab
sapayth bf99c43
initial modal
sapayth b8db203
dynamic templates and hover effects
sapayth 9b4437f
add test for form modal
sapayth 35b9fcf
add fields initial design
sapayth 2a1ce0b
search field functionality
sapayth ba23a52
dynamic search and clear icon
sapayth 56e9a33
pro fields icon and styling
sapayth e3f9a4f
post content field
sapayth 7ab496b
highlight selected field
sapayth 6710ad9
select, multi-select, content restriction
sapayth 0363606
select fields
sapayth cbe19ad
dropdown field
sapayth 178f8f0
dropdown options
sapayth b978ab5
enhance recaptcha field
sapayth 3aaa5de
fix multiple fields
sapayth d626f9b
reg form backward compatibility
sapayth e5201fc
backward compatibility
sapayth 90c62f9
css fixes
sapayth 286a488
js warning
sapayth f561dd1
qa followup 1 to 25
sapayth 6657551
dragging inside column field
sapayth 689dd70
icons, blank state
sapayth b06bc5c
fix dropdown list css
sapayth 5139424
fix dragging after field search
sapayth 579dba6
add canny link for new field
sapayth 4b65706
pro field supports
sapayth ad480f8
hidden fields
sapayth 879ee1b
dropdown options, show values, sync values design
sapayth ceb6a49
fix radio css
sapayth 78bcb6a
hide multistep toggle on free
sapayth 1617bf1
merge mixins
sapayth 9090d49
field size preview
sapayth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
183 changes: 183 additions & 0 deletions
183
admin/form-builder/assets/js/components/builder-stage-v4-1/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
Vue.component('builder-stage-v4-1', { | ||
template: '#tmpl-wpuf-builder-stage-v4-1', | ||
|
||
mixins: wpuf_form_builder_mixins(wpuf_mixins.builder_stage).concat(wpuf_mixins.add_form_field), | ||
|
||
computed: { | ||
form_fields: function () { | ||
return this.$store.state.form_fields; | ||
}, | ||
|
||
field_settings: function () { | ||
return this.$store.state.field_settings; | ||
}, | ||
|
||
hidden_fields: function () { | ||
return this.$store.state.form_fields.filter(function (item) { | ||
return 'custom_hidden_field' === item.template; | ||
}); | ||
}, | ||
|
||
editing_form_id: function () { | ||
return this.$store.state.editing_field_id; | ||
}, | ||
|
||
pro_link: function () { | ||
return wpuf_form_builder.pro_link; | ||
} | ||
}, | ||
|
||
mounted: function () { | ||
var self = this, | ||
in_column_field = false; | ||
|
||
// bind jquery ui sortable | ||
$('#form-preview-stage, #form-preview-stage .wpuf-form.sortable-list').sortable({ | ||
placeholder: 'form-preview-stage-dropzone', | ||
items: '.field-items', | ||
handle: '.field-buttons .move', | ||
scroll: true, | ||
over: function() { | ||
in_column_field = false; | ||
|
||
// if the field drop in column field, then stop field rendering in the builder stage | ||
$(".wpuf-column-inner-fields" ).on( "drop", function(event) { | ||
var targetColumn = event.currentTarget.classList, | ||
isColumnExist = $.inArray(".wpuf-column-inner-fields", targetColumn); | ||
|
||
if ( isColumnExist ) { | ||
in_column_field = true; | ||
} | ||
} ); | ||
}, | ||
update: function (e, ui) { | ||
var item = ui.item[0], | ||
data = item.dataset, | ||
source = data.source, | ||
toIndex = parseInt($(ui.item).index()), | ||
payload = { | ||
toIndex: toIndex | ||
}; | ||
|
||
if ('panel' === source) { | ||
// add new form element | ||
self.$store.state.index_to_insert = parseInt(toIndex); | ||
|
||
if ( ! in_column_field ) { | ||
var field_template = ui.item[0].dataset.formField; | ||
self.add_form_field(field_template); | ||
} | ||
|
||
// remove button from stage | ||
$(this).find('.wpuf-field-button').remove(); | ||
|
||
} else if ('stage' === source) { | ||
payload.fromIndex = parseInt(data.index); | ||
|
||
self.$store.commit('swap_form_field_elements', payload); | ||
} | ||
|
||
} | ||
}); | ||
}, | ||
|
||
methods: { | ||
open_field_settings: function(field_id) { | ||
this.$store.commit('open_field_settings', field_id); | ||
}, | ||
|
||
clone_field: function(field_id, index) { | ||
var payload = { | ||
field_id: field_id, | ||
index: index, | ||
new_id: this.get_random_id() | ||
}; | ||
|
||
// single instance checking | ||
var field = _.find(this.$store.state.form_fields, function (item) { | ||
return parseInt(item.id) === parseInt(payload.field_id); | ||
}); | ||
|
||
// check if these are already inserted | ||
if ( this.isSingleInstance( field.template ) && this.containsField( field.template ) ) { | ||
Swal.fire({ | ||
title: "Oops...", | ||
text: "You already have this field in the form" | ||
}); | ||
return; | ||
} | ||
|
||
this.$store.commit('clone_form_field_element', payload); | ||
}, | ||
|
||
delete_field: function(index) { | ||
var self = this; | ||
|
||
(Swal.fire({ | ||
text: self.i18n.delete_field_warn_msg, | ||
icon: 'warning', | ||
showCancelButton: true, | ||
confirmButtonColor: '#d54e21', | ||
confirmButtonText: self.i18n.yes_delete_it, | ||
cancelButtonText: self.i18n.no_cancel_it, | ||
customClass: { | ||
confirmButton: 'btn btn-success', | ||
cancelButton: 'btn btn-danger', | ||
} | ||
})).then((result) => { | ||
if (result.isConfirmed) { | ||
self.$store.commit('delete_form_field_element', index); | ||
} | ||
}); | ||
}, | ||
|
||
delete_hidden_field: function (field_id) { | ||
var i = 0; | ||
|
||
for (i = 0; i < this.form_fields.length; i++) { | ||
if (parseInt(field_id) === parseInt(this.form_fields[i].id)) { | ||
this.delete_field(i); | ||
} | ||
} | ||
}, | ||
|
||
is_pro_feature: function (template) { | ||
return ( this.field_settings[template] && this.field_settings[template].pro_feature ) ? true : false; | ||
}, | ||
|
||
is_template_available: function (field) { | ||
var template = field.template; | ||
|
||
if (this.field_settings[template]) { | ||
if (this.is_pro_preview(template)) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
// for example see 'mixin_builder_stage' mixin's 'is_taxonomy_template_available' method | ||
if (_.isFunction(this['is_' + template + '_template_available'])) { | ||
return this['is_' + template + '_template_available'].call(this, field); | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
is_full_width: function (template) { | ||
if (this.field_settings[template] && this.field_settings[template].is_full_width) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}, | ||
|
||
is_invisible: function (field) { | ||
return ( field.recaptcha_type && 'invisible_recaptcha' === field.recaptcha_type ) ? true : false; | ||
}, | ||
|
||
get_field_name: function (template) { | ||
return this.field_settings[template].title; | ||
} | ||
} | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve jQuery UI integration with Vue.
Several concerns in the sortable implementation:
self.$store.state.index_to_insert
) violates Vuex patternsConsider these improvements:
Example refactor for the state mutation: