本文整理匯總了TypeScript中app/services/global.service.GlobalService.slugify方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript service.GlobalService.slugify方法的具體用法?TypeScript service.GlobalService.slugify怎麽用?TypeScript service.GlobalService.slugify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app/services/global.service.GlobalService
的用法示例。
在下文中一共展示了service.GlobalService.slugify方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: addCategory
addCategory(newName: string, newWeight: number) {
if (newName) {
let categoryObject = {
name: newName,
weight: newWeight,
slug: this.globalService.slugify(newName),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
updatedBy: this.currentAdmin.uid,
entityKey: this.editMode && this.categoryKey ? this.categoryKey : null,
products: this.newProducts ? this.newProducts : null
};
if (this.editMode && this.categoryKey) {
this.db.object('/categories/' + this.categoryKey).update(categoryObject);
} else {
this.categories.push(categoryObject).then((item) => {
this.db.object('/categories/' + item.key + '/entityKey').set(item.key);
});
}
let snackBarRef = this.snackBar.open('Category saved', 'OK!', {
duration: 3000
});
}
this.validateFields(newName);
}
示例2: submitForModeration
submitForModeration(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
if (!newPublished) {
newPublished = false;
}
if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {
let approvalObject = {
entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.productKey,
url: this.globalService.slugify(newTitle),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
title: newTitle,
thumbnail: this.newThumbnail ? this.newThumbnail : null,
description: newDescription,
price: newPrice,
published: newPublished,
weight: newWeight,
updatedBy: this.currentAdmin.uid,
category: newCategory ? newCategory : null
};
if (this.editMode && this.productKey) {
this.currentModeratedProducts = this.db.list('/approvals/products/');
let adminApprovalProducts = this.db.list('/approvals/products/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
adminApprovalProducts.take(1).subscribe((approvals:any) => {
let matchingApprovals = [];
if (this.router.url.includes('approval')) {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.entityObject.entityKey;
});
} else {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.productKey;
});
}
if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
this.currentModeratedProducts.push(approvalObject);
} else {
this.db.object('/approvals/products/' + this.productKey).update(approvalObject);
}
});
} else {
this.db.list('/approvals/products/').push(approvalObject);
}
let snackBarRef = this.snackBar.open('Product submitted for moderation', 'OK!', {
duration: 3000
});
snackBarRef.onAction().subscribe(() => {
this.router.navigateByUrl('admin/approvals');
});
}
this.validateFields(newTitle, newDescription, newPrice);
}
示例3: submitForModeration
submitForModeration(newName: string, newWeight: number) {
if (newName && this.currentAdmin.uid) {
let approvalObject = {
entityKey: this.router.url.includes('approval') ? this.entityObject.entityKey : this.categoryKey,
name: newName,
weight: newWeight,
slug: this.globalService.slugify(newName),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
updatedBy: this.currentAdmin.uid,
products: this.newProducts ? this.newProducts : null
};
if (this.editMode && this.categoryKey) {
this.currentModeratedCategories = this.db.list('/approvals/categories/');
let adminApprovalCategories = this.db.list('/approvals/categories/', ref => ref.orderByChild('updatedBy').equalTo(this.currentAdmin.uid)).valueChanges();
adminApprovalCategories.take(1).subscribe((approvals:any) => {
let matchingApprovals = [];
if (this.router.url.includes('approval')) {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.entityObject.entityKey;
});
} else {
matchingApprovals = approvals.filter((match) => {
return match.entityKey === this.categoryKey;
});
}
if (matchingApprovals.length === 0 || !this.router.url.includes('approval')) {
this.currentModeratedCategories.push(approvalObject);
} else {
this.db.object('/approvals/categories/' + this.categoryKey).update(approvalObject);
}
});
} else {
this.db.list('/approvals/categories/').push(approvalObject);
}
let snackBarRef = this.snackBar.open('Category submitted for moderation', 'OK!', {
duration: 3000
});
snackBarRef.onAction().subscribe(() => {
this.router.navigateByUrl('admin/approvals');
});
}
this.validateFields(newName);
}
示例4: addProduct
addProduct(newTitle: string, newPrice: string, newCategory: any, newWeight: number, newDescription: string, newPublished: boolean) {
if (!newPublished) {
newPublished = false;
}
if (newTitle && newPrice && newDescription && this.currentAdmin.uid) {
let productObject = {
url: this.globalService.slugify(newTitle),
dateUpdated: Date.now().toString(),
rdateUpdated: (Date.now() * -1).toString(),
title: newTitle,
thumbnail: this.newThumbnail ? this.newThumbnail : null,
description: newDescription,
price: newPrice,
published: newPublished,
updatedBy: this.currentAdmin.uid,
weight: newWeight,
category: newCategory ? newCategory : null,
entityKey: this.editMode && this.productKey ? this.productKey : null
};
// if (this.imageUrl && !this.newThumbnail) {
// this.deleteImageRef();
// }
if (this.editMode && this.productKey) {
this.currentProduct = this.db.object('/products/' + this.productKey);
this.currentProduct.update(productObject);
this.updateCategory(this.ogCategory, this.newCategory, this.productKey);
} else {
this.products.push(productObject).then((item) => {
if (this.newCategory) {
this.db.object('/products/' + item.key + '/entityKey').set(item.key);
this.db.object('/categories/' + this.newCategory + '/products/' + item.key).set(Date.now().toString());
}
});
}
let snackBarRef = this.snackBar.open('Product saved', 'OK!', {
duration: 3000
});
}
this.validateFields(newTitle, newDescription, newPrice);
}