Added auto generated offer code for new offers

closes https://github.com/TryGhost/Team/issues/1784

- auto generates offer code for new offers from name, same as display name
- stops auto generation as soon as offer code is manually edited once
This commit is contained in:
Rishabh 2022-08-12 16:20:26 +05:30
parent 7ea1c2591b
commit 00f2c73d93

View File

@ -57,6 +57,7 @@ export default class OffersController extends Controller {
@tracked defaultProps = null;
@tracked isDisplayTitleEdited = false;
@tracked isOfferCodeEdited = false;
leaveScreenTransition = null;
portalPreviewGuid = Date.now().valueOf();
@ -335,6 +336,10 @@ export default class OffersController extends Controller {
if (!this.isDisplayTitleEdited && this.offer.isNew) {
this._saveOfferProperty('displayTitle', e.target.value);
}
if (!this.isOfferCodeEdited && this.offer.isNew) {
this._saveOfferProperty('code', slugify(e.target.value));
}
}
@action
@ -350,6 +355,7 @@ export default class OffersController extends Controller {
@action
setOfferCode(e) {
this.isOfferCodeEdited = true;
this._saveOfferProperty('code', e.target.value);
}