mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51: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 uploadSync = Meteor.wrapAsync(Cloudinary.uploader.upload);
|
||||
const cloudinarySettings = getSetting("cloudinary");
|
||||
|
||||
Cloudinary.config({
|
||||
cloud_name: getSetting("cloudinaryCloudName"),
|
||||
api_key: getSetting("cloudinaryAPIKey"),
|
||||
api_secret: getSetting("cloudinaryAPISecret"),
|
||||
cloud_name: cloudinarySettings.cloudName,
|
||||
api_key: cloudinarySettings.apiKey,
|
||||
api_secret: cloudinarySettings.apiSecret,
|
||||
secure: true,
|
||||
});
|
||||
|
||||
|
@ -33,7 +34,7 @@ const CloudinaryUtils = {
|
|||
|
||||
// generate signed URL for each format based off public_id
|
||||
getUrls(cloudinaryId) {
|
||||
return getSetting("cloudinaryFormats").map(format => {
|
||||
return cloudinarySettings.formats.map(format => {
|
||||
const url = Cloudinary.url(cloudinaryId, {
|
||||
width: format.width,
|
||||
height: format.height,
|
||||
|
@ -90,7 +91,7 @@ Meteor.methods({
|
|||
|
||||
// post submit callback
|
||||
function cachePostThumbnailOnSubmit (post) {
|
||||
if (getSetting("cloudinaryAPIKey")) {
|
||||
if (cloudinarySettings) {
|
||||
if (post.thumbnailUrl) {
|
||||
|
||||
const data = CloudinaryUtils.uploadImage(post.thumbnailUrl);
|
||||
|
@ -106,7 +107,7 @@ function cachePostThumbnailOnSubmit (post) {
|
|||
addCallback("posts.new.sync", cachePostThumbnailOnSubmit);
|
||||
|
||||
function cachePostThumbnailOnEdit (modifier, oldPost) {
|
||||
if (getSetting("cloudinaryAPIKey")) {
|
||||
if (cloudinarySettings) {
|
||||
if (modifier.$set.thumbnailUrl && modifier.$set.thumbnailUrl !== oldPost.thumbnailUrl) {
|
||||
const data = CloudinaryUtils.uploadImage(modifier.$set.thumbnailUrl);
|
||||
modifier.$set.cloudinaryId = data.cloudinaryId;
|
||||
|
|
|
@ -60,6 +60,7 @@ class Form extends Component {
|
|||
this.mutationErrorCallback = this.mutationErrorCallback.bind(this);
|
||||
this.addToAutofilledValues = this.addToAutofilledValues.bind(this);
|
||||
this.addToDeletedValues = this.addToDeletedValues.bind(this);
|
||||
this.addToSubmitForm = this.addToSubmitForm.bind(this);
|
||||
this.throwError = this.throwError.bind(this);
|
||||
this.clearForm = this.clearForm.bind(this);
|
||||
this.updateCurrentValues = this.updateCurrentValues.bind(this);
|
||||
|
@ -380,6 +381,7 @@ class Form extends Component {
|
|||
updateCurrentValues: this.updateCurrentValues,
|
||||
getDocument: this.getDocument,
|
||||
setFormState: this.setFormState,
|
||||
addToSubmitForm: this.addToSubmitForm,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -450,7 +452,7 @@ class Form extends Component {
|
|||
|
||||
// run data object through submitForm callbacks
|
||||
data = runCallbacks(this.submitFormCallbacks, data);
|
||||
|
||||
|
||||
const fields = this.getFieldNames();
|
||||
|
||||
// if there's a submit callback, run it
|
||||
|
@ -529,8 +531,12 @@ class Form extends Component {
|
|||
>
|
||||
{this.renderErrors()}
|
||||
{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>
|
||||
|
||||
{
|
||||
|
@ -567,6 +573,8 @@ Form.propTypes = {
|
|||
layout: PropTypes.string,
|
||||
fields: PropTypes.arrayOf(PropTypes.string),
|
||||
showRemove: PropTypes.bool,
|
||||
submitLabel: PropTypes.string,
|
||||
cancelLabel: PropTypes.string,
|
||||
|
||||
// callbacks
|
||||
submitCallback: PropTypes.func,
|
||||
|
|
Loading…
Add table
Reference in a new issue