Skip to content

Commit

Permalink
Grab correct data from API response
Browse files Browse the repository at this point in the history
  • Loading branch information
binarykitchen committed Dec 21, 2024
1 parent ab1e48e commit c42419e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
15 changes: 9 additions & 6 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const VideomailFieldController = Marionette.Object.extend({
quality: imageQualityPercentage / 100, // must be a float
},
selectors: {
containerId: "videomail",
submitButtonSelector: ".submit-wrap input",
},
callbacks: {
Expand Down Expand Up @@ -136,7 +137,7 @@ const VideomailFieldController = Marionette.Object.extend({
.request("remove:error", this.fieldModel.get("id"), "required-error");
},

onSubmitted: function (videomail) {
onSubmitted: function (result) {
let formModel = Backbone.Radio.channel("app").request("get:form", this.getFormId());

if (!formModel) {
Expand All @@ -148,7 +149,7 @@ const VideomailFieldController = Marionette.Object.extend({
Backbone.Radio.channel("form-" + formModel.get("id")).request(
"add:extra",
"videomail",
videomail,
result.videomail,
);

// restart submission again, this time to the real wp site
Expand All @@ -171,7 +172,7 @@ const VideomailFieldController = Marionette.Object.extend({
},

invalidate: function () {
// override default behaviour so that we can set our own error text here
// override default behavior so that we can set our own error text here
Backbone.Radio.channel("fields").request(
"add:error",
this.fieldModel.get("id"),
Expand Down Expand Up @@ -254,21 +255,23 @@ const VideomailFieldController = Marionette.Object.extend({
collection = this.fieldModel.collection.options.formModel.get("fields").models;
}

return collection.reduce(function (memo, field) {
const formValues = collection.reduce(function (memo, field) {
memo[field.get("key")] = field.get("value");
return memo;
}, {});

return formValues;
},

adjustFormDataBeforePostingToVideomailServer: function (videomail, cb) {
adjustFormDataBeforePostingToVideomailServer: function (videomail) {
const formValues = this.getFormValues();

videomail.from = this.getMergeTagValue("email_from", formValues);
videomail.to = this.getMergeTagValue("email_to", formValues);
videomail.subject = this.getMergeTagValue("email_subject", formValues);
videomail.body = this.getMergeTagValue("email_body", formValues);

cb(null, videomail);
return videomail;
},

onBeforeDestroy: function () {
Expand Down
8 changes: 4 additions & 4 deletions src/php/templates/fields-videomail.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script id="tmpl-nf-field-videomail" type="text/template">
<div id='nf-field-{{{ data.id }}}' name='nf-field-{{{ data.id }}}' class='{{{ data.classes }}} nf-element videomail'>
<form id='videomail'>
<div class='buttons' style='display:none'>
<div id='videomail'>
<section class='buttons' style='display:none'>
<input class='record' disabled='' type='button' title='Record video' value='Record' />
<input class='pause' disabled='' type='button' title='Pause recording' value='Pause' />
<input class='resume' disabled='' type='button' title='Resume recording' value='Resume' />
<input class='preview' disabled='' type='button' title='Stop recording and check video' value='Stop' />
<input class='recordAgain' disabled='' type='button' title='Record video again' value='Record again' />
</div>
</form>
</section>
</div>
<div id='viewVideo' style='display:none'>
<video class='replay' />
<button id='startOver'>Start over</button>
Expand Down
7 changes: 7 additions & 0 deletions src/styl/main.styl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ border-radius = 2px
input[type=button]
margin-top 5px
margin-right 0.5em
padding 0.6em
cursor pointer

&:focus
outline 0

&:disabled
cursor not-allowed
transition none
opacity 0.5
2 changes: 1 addition & 1 deletion target/css/main.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions target/js/main.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions target/php/templates/fields-videomail.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script id="tmpl-nf-field-videomail" type="text/template">
<div id='nf-field-{{{ data.id }}}' name='nf-field-{{{ data.id }}}' class='{{{ data.classes }}} nf-element videomail'>
<form id='videomail'>
<div class='buttons' style='display:none'>
<div id='videomail'>
<section class='buttons' style='display:none'>
<input class='record' disabled='' type='button' title='Record video' value='Record' />
<input class='pause' disabled='' type='button' title='Pause recording' value='Pause' />
<input class='resume' disabled='' type='button' title='Resume recording' value='Resume' />
<input class='preview' disabled='' type='button' title='Stop recording and check video' value='Stop' />
<input class='recordAgain' disabled='' type='button' title='Record video again' value='Record again' />
</div>
</form>
</section>
</div>
<div id='viewVideo' style='display:none'>
<video class='replay' />
<button id='startOver'>Start over</button>
Expand Down

0 comments on commit c42419e

Please sign in to comment.