$w("#emptyHeart1").onClick((event) => { wixData.get("Members", memberId) .then((memberInfo) => { $w('#emptyHeart1').collapse(); $w('#fullHeart1').expand(); $w('#likes1').text = (parseInt($w('#likes1').text) + 1).toString(); memberInfo.likes1 = true; wixData.update('Members', memberInfo).catch(); }) });
$w("#fullHeart1").onClick((event) => { wixData.get("Members", memberId) .then((memberInfo) => { $w('#fullHeart1').collapse(); $w('#emptyHeart1').expand(); $w('#likes1').text = (parseInt($w('#likes1').text) - 1).toString(); memberInfo.likes1 = true; wixData.update('Members', memberInfo).catch(); }) });
import wixData from 'wix-data'; export function Members_beforeUpdate(item, context) { if (item.likes) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes ? itemToUpdate.likes += 1 : itemToUpdate.likes = 1; return itemToUpdate; }) } return item; }
import wixData from 'wix-data'; export function Members_beforeUpdate(item, context) { if (item.likes) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes ? itemToUpdate.likes += 1 : itemToUpdate.likes = 1; return itemToUpdate; }) } return item; }
import wixData from 'wix-data';
export function Members_beforeUpdate(item, context) {
if (item.likes === 1 || item.likes === -1) {
return wixData.get(context.collectionName, item._id, { "suppressHooks": true })
.then(itemToUpdate => {
if (typeof itemToUpdate.likes !== 'number') {
itemToUpdate.likes = 0;
}
itemToUpdate.likes += item.likes;
if (itemToUpdate.likes < 1) {
itemToUpdate.likes = false;
}
return itemToUpdate;
});
}
return item;
}
import wixData from 'wix-data';
export function Members_beforeUpdate(item, context) {
if (item.likes === 1 || item.likes === -1) {
return wixData.get(context.collectionName, item._id, { "suppressHooks": true })
.then(itemToUpdate => {
if (typeof itemToUpdate.likes !== 'number') {
itemToUpdate.likes = 0;
}
itemToUpdate.likes += item.likes;
if (itemToUpdate.likes < 1) {
itemToUpdate.likes = false;
}
return itemToUpdate;
});
}
return item;
}
import wixData from 'wix-data'; export function Members_likes1(item, context) { if (item.likes1) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes1 ? itemToUpdate.likes1 += 1 : itemToUpdate.likes1 = 1; return itemToUpdate; }) } return item; } export function Members_likes2(item, context) { if (item.likes2) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes2 ? itemToUpdate.likes2 += 1 : itemToUpdate.likes2 = 1; return itemToUpdate; }) } return item; } export function Members_likes3(item, context) { if (item.likes3) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes3 ? itemToUpdate.likes3 += 1 : itemToUpdate.likes3 = 1; return itemToUpdate; }) } return item; } export function Members_likes4(item, context) { if (item.likes4) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes4 ? itemToUpdate.likes4 += 1 : itemToUpdate.likes4 = 1; return itemToUpdate; }) } return item; } export function Members_likes5(item, context) { if (item.likes5) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes5 ? itemToUpdate.likes5 += 1 : itemToUpdate.likes5 = 1; return itemToUpdate; }) } return item; } export function Members_likes6(item, context) { if (item.likes6) { return wixData.get(context.collectionName, item._id, { "suppressHooks": true }) .then(itemToUpdate => { itemToUpdate.likes6 ? itemToUpdate.likes6 += 1 : itemToUpdate.likes6 = 1; return itemToUpdate; }) } return item; }
let url = wixLocation.url; let memberId = url.substr(url.lastIndexOf("/") + 1); $w.onReady(async function () { let memberInfo = await Members_likes1(memberId); $w("#emptyHeart1").onClick((event) => { $w("#likes1").text = (memberInfo.likes1); $w('#emptyHeart1').collapse(); $w('#fullHeart1').expand(); $w('#likes1').text = (parseInt($w('#likes1').text) + 1).toString(); memberInfo.Members_likes1 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes1(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes1: "0", }; } } }) $w.onReady(async function () { let memberInfo = await Members_likes2(memberId); $w("#emptyHeart2").onClick((event) => { $w("#likes2").text = (memberInfo.likes2); $w('#emptyHeart2').collapse(); $w('#fullHeart2').expand(); $w('#likes2').text = (parseInt($w('#likes2').text) + 1).toString(); memberInfo.likes2 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes2(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes2: "0", }; } } }) $w.onReady(async function () { let memberInfo = await Members_likes3(memberId); $w("#emptyHeart3").onClick((event) => { $w("#likes3").text = (memberInfo.likes3); $w('#emptyHeart3').collapse(); $w('#fullHeart3').expand(); $w('#likes3').text = (parseInt($w('#likes3').text) + 1).toString(); memberInfo.likes3 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes3(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes3: "0", }; } } }) $w.onReady(async function () { let memberInfo = await Members_likes4(memberId); $w("#emptyHeart4").onClick((event) => { $w("#likes4").text = (memberInfo.likes4); $w('#emptyHeart4').collapse(); $w('#fullHeart4').expand(); $w('#likes4').text = (parseInt($w('#likes4').text) + 1).toString(); memberInfo.likes4 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes4(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes4: "0", }; } } }) $w.onReady(async function () { let memberInfo = await Members_likes5(memberId); $w("#emptyHeart5").onClick((event) => { $w("#likes5").text = (memberInfo.likes5); $w('#emptyHeart5').collapse(); $w('#fullHeart5').expand(); $w('#likes5').text = (parseInt($w('#likes5').text) + 1).toString(); memberInfo.likes5 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes5(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes5: "0", }; } } }) $w.onReady(async function () { let memberInfo = await Members_likes6(memberId); $w("#emptyHeart6").onClick((event) => { $w("#likes6").text = (memberInfo.likes6); $w('#emptyHeart6').collapse(); $w('#fullHeart6').expand(); $w('#likes6').text = (parseInt($w('#likes6').text) + 1).toString(); memberInfo.likes6 = true; wixData.update("Members", memberInfo).then(() => { $w("#dynamicDataset").refresh();}) }); async function Members_likes6(memberId) { let query = wixData.query("Members") .eq("_id", memberId) .find(); let results = await query; if (results.items.length > 0) { return results.items[0]; } else { console.error(`Member with ID ${memberId} not found`); return { likes6: "0", }; } } })
const date = $w("#registerDate").text = (memberInfo._createdDate);
Du måste vara medlem för att kunna kommentera
Flashback finansieras genom donationer från våra medlemmar och besökare. Det är med hjälp av dig vi kan fortsätta erbjuda en fri samhällsdebatt. Tack för ditt stöd!
Swish: 123 536 99 96 Bankgiro: 211-4106