mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-03 23:14:13 +00:00 
			
		
		
		
	enhance(client): 広告・お知らせが新規登録時に増殖しないように (#10412)
This commit is contained in:
		
							parent
							
								
									6892e9fbb7
								
							
						
					
					
						commit
						5cd93834d1
					
				
					 2 changed files with 51 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -113,16 +113,37 @@ function remove(ad) {
 | 
			
		|||
 | 
			
		||||
function save(ad) {
 | 
			
		||||
	if (ad.id == null) {
 | 
			
		||||
		os.apiWithDialog('admin/ad/create', {
 | 
			
		||||
		os.api('admin/ad/create', {
 | 
			
		||||
			...ad,
 | 
			
		||||
			expiresAt: new Date(ad.expiresAt).getTime(),
 | 
			
		||||
			startsAt: new Date(ad.startsAt).getTime(),
 | 
			
		||||
		}).then(() => {
 | 
			
		||||
			os.alert({
 | 
			
		||||
				type: 'success',
 | 
			
		||||
				text: i18n.ts.saved,
 | 
			
		||||
			});
 | 
			
		||||
			refresh();
 | 
			
		||||
		}).catch(err => {
 | 
			
		||||
			os.alert({
 | 
			
		||||
				type: 'error',
 | 
			
		||||
				text: err,
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
	} else {
 | 
			
		||||
		os.apiWithDialog('admin/ad/update', {
 | 
			
		||||
		os.api('admin/ad/update', {
 | 
			
		||||
			...ad,
 | 
			
		||||
			expiresAt: new Date(ad.expiresAt).getTime(),
 | 
			
		||||
			startsAt: new Date(ad.startsAt).getTime(),
 | 
			
		||||
		}).then(() => {
 | 
			
		||||
			os.alert({
 | 
			
		||||
				type: 'success',
 | 
			
		||||
				text: i18n.ts.saved,
 | 
			
		||||
			});
 | 
			
		||||
		}).catch(err => {
 | 
			
		||||
			os.alert({
 | 
			
		||||
				type: 'error',
 | 
			
		||||
				text: err,
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -141,6 +162,25 @@ function more() {
 | 
			
		|||
		}));
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function refresh() {
 | 
			
		||||
	os.api('admin/ad/list').then(adsResponse => {
 | 
			
		||||
		ads = adsResponse.map(r => {
 | 
			
		||||
			const exdate = new Date(r.expiresAt);
 | 
			
		||||
			const stdate = new Date(r.startsAt);
 | 
			
		||||
			exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff);
 | 
			
		||||
			stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff);
 | 
			
		||||
			return {
 | 
			
		||||
				...r,
 | 
			
		||||
				expiresAt: exdate.toISOString().slice(0, 16),
 | 
			
		||||
				startsAt: stdate.toISOString().slice(0, 16),
 | 
			
		||||
			};
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
refresh();
 | 
			
		||||
 | 
			
		||||
const headerActions = $computed(() => [{
 | 
			
		||||
	asFullButton: true,
 | 
			
		||||
	icon: 'ti ti-plus',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,7 @@ function save(announcement) {
 | 
			
		|||
				type: 'success',
 | 
			
		||||
				text: i18n.ts.saved,
 | 
			
		||||
			});
 | 
			
		||||
			refresh();
 | 
			
		||||
		}).catch(err => {
 | 
			
		||||
			os.alert({
 | 
			
		||||
				type: 'error',
 | 
			
		||||
| 
						 | 
				
			
			@ -90,6 +91,14 @@ function save(announcement) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function refresh() {
 | 
			
		||||
	os.api('admin/announcements/list').then(announcementResponse => {
 | 
			
		||||
		announcements = announcementResponse;
 | 
			
		||||
	});
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
refresh();
 | 
			
		||||
 | 
			
		||||
const headerActions = $computed(() => [{
 | 
			
		||||
	asFullButton: true,
 | 
			
		||||
	icon: 'ti ti-plus',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue