mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
add submitLabel and cancelLabel SmartForms props; change cloudinary setting name to cloudinary
This commit is contained in:
parent
bd192a5488
commit
18079b9d30
2 changed files with 18 additions and 9 deletions
|
@ -5,11 +5,12 @@ import { addCallback, Utils, getSetting } from 'meteor/vulcan:core';
|
||||||
|
|
||||||
const Cloudinary = cloudinary.v2;
|
const Cloudinary = cloudinary.v2;
|
||||||
const uploadSync = Meteor.wrapAsync(Cloudinary.uploader.upload);
|
const uploadSync = Meteor.wrapAsync(Cloudinary.uploader.upload);
|
||||||
|
const cloudinarySettings = getSetting("cloudinary");
|
||||||
|
|
||||||
Cloudinary.config({
|
Cloudinary.config({
|
||||||
cloud_name: getSetting("cloudinaryCloudName"),
|
cloud_name: cloudinarySettings.cloudName,
|
||||||
api_key: getSetting("cloudinaryAPIKey"),
|
api_key: cloudinarySettings.apiKey,
|
||||||
api_secret: getSetting("cloudinaryAPISecret"),
|
api_secret: cloudinarySettings.apiSecret,
|
||||||
secure: true,
|
secure: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ const CloudinaryUtils = {
|
||||||
|
|
||||||
// generate signed URL for each format based off public_id
|
// generate signed URL for each format based off public_id
|
||||||
getUrls(cloudinaryId) {
|
getUrls(cloudinaryId) {
|
||||||
return getSetting("cloudinaryFormats").map(format => {
|
return cloudinarySettings.formats.map(format => {
|
||||||
const url = Cloudinary.url(cloudinaryId, {
|
const url = Cloudinary.url(cloudinaryId, {
|
||||||
width: format.width,
|
width: format.width,
|
||||||
height: format.height,
|
height: format.height,
|
||||||
|
@ -90,7 +91,7 @@ Meteor.methods({
|
||||||
|
|
||||||
// post submit callback
|
// post submit callback
|
||||||
function cachePostThumbnailOnSubmit (post) {
|
function cachePostThumbnailOnSubmit (post) {
|
||||||
if (getSetting("cloudinaryAPIKey")) {
|
if (cloudinarySettings) {
|
||||||
if (post.thumbnailUrl) {
|
if (post.thumbnailUrl) {
|
||||||
|
|
||||||
const data = CloudinaryUtils.uploadImage(post.thumbnailUrl);
|
const data = CloudinaryUtils.uploadImage(post.thumbnailUrl);
|
||||||
|
@ -106,7 +107,7 @@ function cachePostThumbnailOnSubmit (post) {
|
||||||
addCallback("posts.new.sync", cachePostThumbnailOnSubmit);
|
addCallback("posts.new.sync", cachePostThumbnailOnSubmit);
|
||||||
|
|
||||||
function cachePostThumbnailOnEdit (modifier, oldPost) {
|
function cachePostThumbnailOnEdit (modifier, oldPost) {
|
||||||
if (getSetting("cloudinaryAPIKey")) {
|
if (cloudinarySettings) {
|
||||||
if (modifier.$set.thumbnailUrl && modifier.$set.thumbnailUrl !== oldPost.thumbnailUrl) {
|
if (modifier.$set.thumbnailUrl && modifier.$set.thumbnailUrl !== oldPost.thumbnailUrl) {
|
||||||
const data = CloudinaryUtils.uploadImage(modifier.$set.thumbnailUrl);
|
const data = CloudinaryUtils.uploadImage(modifier.$set.thumbnailUrl);
|
||||||
modifier.$set.cloudinaryId = data.cloudinaryId;
|
modifier.$set.cloudinaryId = data.cloudinaryId;
|
||||||
|
|
|
@ -60,6 +60,7 @@ class Form extends Component {
|
||||||
this.mutationErrorCallback = this.mutationErrorCallback.bind(this);
|
this.mutationErrorCallback = this.mutationErrorCallback.bind(this);
|
||||||
this.addToAutofilledValues = this.addToAutofilledValues.bind(this);
|
this.addToAutofilledValues = this.addToAutofilledValues.bind(this);
|
||||||
this.addToDeletedValues = this.addToDeletedValues.bind(this);
|
this.addToDeletedValues = this.addToDeletedValues.bind(this);
|
||||||
|
this.addToSubmitForm = this.addToSubmitForm.bind(this);
|
||||||
this.throwError = this.throwError.bind(this);
|
this.throwError = this.throwError.bind(this);
|
||||||
this.clearForm = this.clearForm.bind(this);
|
this.clearForm = this.clearForm.bind(this);
|
||||||
this.updateCurrentValues = this.updateCurrentValues.bind(this);
|
this.updateCurrentValues = this.updateCurrentValues.bind(this);
|
||||||
|
@ -380,6 +381,7 @@ class Form extends Component {
|
||||||
updateCurrentValues: this.updateCurrentValues,
|
updateCurrentValues: this.updateCurrentValues,
|
||||||
getDocument: this.getDocument,
|
getDocument: this.getDocument,
|
||||||
setFormState: this.setFormState,
|
setFormState: this.setFormState,
|
||||||
|
addToSubmitForm: this.addToSubmitForm,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,8 +531,12 @@ class Form extends Component {
|
||||||
>
|
>
|
||||||
{this.renderErrors()}
|
{this.renderErrors()}
|
||||||
{fieldGroups.map(group => <FormGroup key={group.name} {...group} updateCurrentValues={this.updateCurrentValues} />)}
|
{fieldGroups.map(group => <FormGroup key={group.name} {...group} updateCurrentValues={this.updateCurrentValues} />)}
|
||||||
<Button type="submit" bsStyle="primary"><FormattedMessage id="forms.submit"/></Button>
|
|
||||||
{this.props.cancelCallback ? <a className="form-cancel" onClick={this.props.cancelCallback}><FormattedMessage id="forms.cancel"/></a> : null}
|
<div className="form-submit">
|
||||||
|
<Button type="submit" bsStyle="primary">{this.props.submitLabel ? this.props.submitLabel : <FormattedMessage id="forms.submit"/>}</Button>
|
||||||
|
{this.props.cancelCallback ? <a className="form-cancel" onClick={this.props.cancelCallback}>{this.props.cancelLabel ? this.props.cancelLabel : <FormattedMessage id="forms.cancel"/>}</a> : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
</Formsy.Form>
|
</Formsy.Form>
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -567,6 +573,8 @@ Form.propTypes = {
|
||||||
layout: PropTypes.string,
|
layout: PropTypes.string,
|
||||||
fields: PropTypes.arrayOf(PropTypes.string),
|
fields: PropTypes.arrayOf(PropTypes.string),
|
||||||
showRemove: PropTypes.bool,
|
showRemove: PropTypes.bool,
|
||||||
|
submitLabel: PropTypes.string,
|
||||||
|
cancelLabel: PropTypes.string,
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
submitCallback: PropTypes.func,
|
submitCallback: PropTypes.func,
|
||||||
|
|
Loading…
Add table
Reference in a new issue