Skip to content

Commit 9d5d825

Browse files
committed
copyrighteditable
1 parent 535be26 commit 9d5d825

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

pages/admin/pages/search.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BasicEntry } from "shared/components.ts";
22
import { ProfileData, RegisterAuthRefresh, sheetStack, showProfilePicture } from "shared/helper.ts";
33
import { placeholder } from "shared/mod.ts";
4-
import { asRef, Box, Content, createCachedLoader, createIndexPaginationLoader, createPage, createRoute, DateInput, DropDown, Empty, Entry, Grid, Label, PrimaryButton, SheetHeader, Spinner, TextButton, TextInput, WriteSignal } from "webgen/mod.ts";
4+
import { asRef, Box, Checkbox, Content, createCachedLoader, createIndexPaginationLoader, createPage, createRoute, DateInput, DropDown, Empty, Entry, Grid, Label, PrimaryButton, SheetHeader, Spinner, TextButton, TextInput, WriteSignal } from "webgen/mod.ts";
55
import { API, PaymentType, SearchReturn, stupidErrorAlert, User, Wallet, zAccountType } from "../../../spec/mod.ts";
66
import { WalletView } from "../../wallet/component.ts";
77
import { ReviewEntry } from "../entries.ts";
@@ -85,13 +85,26 @@ export const walletSheet = (wallet: WriteSignal<Wallet>) => {
8585
await API.patchIdByWalletsByAdmin({ path: { id: wallet.getValue()._id }, body: { cut: val } }).then(stupidErrorAlert);
8686
wallet.setValue({ ...wallet.getValue(), cut: Number(val) });
8787
});
88+
const copyrightEditable = asRef(wallet.getValue().copyrightEditable ?? false);
89+
copyrightEditable.listen(async (val, oldVal) => {
90+
if (oldVal === undefined) {
91+
return;
92+
}
93+
await API.patchIdByWalletsByAdmin({ path: { id: wallet.getValue()._id }, body: { copyrightEditable: val } }).then(stupidErrorAlert);
94+
wallet.setValue({ ...wallet.getValue(), copyrightEditable: val });
95+
});
96+
8897
return Grid(
8998
SheetHeader("Wallet", sheetStack),
9099
Grid(
91100
DropDown(Object.values(zAccountType.enum), selectedAccountType, "AccountType"),
92101
TextInput(selectedCut, "Cut", "change"),
93102
PrimaryButton("Add Transaction").onClick(() => sheetStack.addSheet(addTransactionSheet(wallet))),
94-
).setEvenColumns(3).setGap(),
103+
Box(
104+
Checkbox(copyrightEditable),
105+
Label("Copyright Editable"),
106+
),
107+
).setEvenColumns(4).setGap(),
95108
wallet.map((wallet) => WalletView(wallet)).value,
96109
);
97110
};

pages/music/edit.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const creationState = asRefRecord({
3939
type: <DropType | undefined> undefined,
4040
});
4141

42+
const disableCopyright = asRef(<boolean> true);
43+
4244
const share = asRef(<undefined | Share> undefined);
4345

4446
const events = asRef(<UserHistoryEvent[]> []);
@@ -75,6 +77,13 @@ const mainRoute = createRoute({
7577

7678
disabled.setValue(drop.type !== "PRIVATE" && drop.type !== "UNSUBMITTED");
7779

80+
if (isAdmin) {
81+
disableCopyright.setValue(disabled.get() || false);
82+
} else {
83+
// @ts-ignore it exists
84+
disableCopyright.setValue(disabled.get() || !(drop.copyrightEditable ?? false));
85+
}
86+
7887
try {
7988
API.getIdByShareByDropsByMusic({ path: { id: id.value } }).then((req) => stupidErrorAlert(req, false)).then((val) => val ? share.setValue(val) : undefined);
8089
// deno-lint-ignore no-empty
@@ -331,8 +340,8 @@ appendBody(
331340
DropDown(getSecondary(genres, creationState.primaryGenre), creationState.secondaryGenre, "Secondary Genre").setDisabled(disabled),
332341
).setEvenColumns(isMobile.map((val) => val ? 1 : 2)).setGap(),
333342
Grid(
334-
TextInput(creationState.compositionCopyright, "Composition Copyright").setDisabled(true),
335-
TextInput(creationState.soundRecordingCopyright, "Sound Recording Copyright").setDisabled(true),
343+
TextInput(creationState.compositionCopyright, "Composition Copyright").setDisabled(disableCopyright),
344+
TextInput(creationState.soundRecordingCopyright, "Sound Recording Copyright").setDisabled(disableCopyright),
336345
TextInput(creationState.gtin, "UPC/EAN").setDisabled(disabled),
337346
).setEvenColumns(isMobile.map((val) => val ? 1 : 3)).setGap(),
338347
).setGap(),
@@ -408,6 +417,7 @@ appendBody(
408417
}),
409418
SecondaryButton("Reenable Edit").onClick(() => {
410419
disabled.setValue(false);
420+
disableCopyright.setValue(false);
411421
}),
412422
PrimaryButton("Accept").onClick((e) => {
413423
if (!(e as PointerEvent).shiftKey) {

pages/music/newDrop.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const creationState = asRefRecord({
4343
comments: <string | undefined> undefined,
4444
page: 0,
4545
validationState: <string | undefined> undefined,
46+
disableCopyright: <boolean>true,
4647
});
4748
API.getIdByDropsByMusic({ path: { id: dropId } }).then(stupidErrorAlert)
4849
.then(async (drop) => {
@@ -59,14 +60,15 @@ API.getIdByDropsByMusic({ path: { id: dropId } }).then(stupidErrorAlert)
5960
creationState.artworkData.setValue(drop.artwork ? await API.getArtworkByDropByMusic({ path: { dropId } }).then((x) => URL.createObjectURL(x.data)) : templateArtwork);
6061
creationState.songs.setValue(drop.songs ?? []);
6162
creationState.comments.setValue(drop.comments);
63+
creationState.disableCopyright.setValue(!(drop.copyrightEditable ?? false))
6264
})
6365
.then(() => creationState.page.setValue(1));
6466

6567
const additionalDropInformation = Grid(
6668
SheetHeader("Additional Information", sheetStack),
6769
TextInput(creationState.gtin, "UPC/EAN"),
68-
TextInput(creationState.compositionCopyright, "Composition Copyright").setDisabled(true),
69-
TextInput(creationState.soundRecordingCopyright, "Sound Recording Copyright").setDisabled(true),
70+
TextInput(creationState.compositionCopyright, "Composition Copyright").setDisabled(creationState.disableCopyright),
71+
TextInput(creationState.soundRecordingCopyright, "Sound Recording Copyright").setDisabled(creationState.disableCopyright),
7072
PrimaryButton("Save").onClick(() => sheetStack.removeOne()),
7173
).setGap();
7274

spec/gen/types.gen.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export type Wallet = {
190190
};
191191
stripeAccountId?: string;
192192
accountType: AccountType;
193+
copyrightEditable: boolean;
193194
};
194195

195196
export type ShazamResults = Array<{
@@ -460,6 +461,7 @@ export type AdminWallet = {
460461
};
461462
stripeAccountId?: string;
462463
accountType: AccountType;
464+
copyrightEditable: boolean;
463465
} & {
464466
email: string;
465467
userName: string;
@@ -867,6 +869,7 @@ export type PatchIdByWalletsByAdminData = {
867869
};
868870
stripeAccountId?: string;
869871
accountType?: AccountType;
872+
copyrightEditable?: boolean;
870873
};
871874
path: {
872875
id: string;
@@ -1214,6 +1217,8 @@ export type GetIdByDropsByMusicResponses = {
12141217
_id?: string;
12151218
user?: string;
12161219
type?: DropType;
1220+
} & {
1221+
copyrightEditable?: boolean;
12171222
};
12181223
};
12191224

@@ -1817,6 +1822,7 @@ export type GetWalletResponses = {
18171822
};
18181823
stripeAccountId?: string;
18191824
accountType: AccountType;
1825+
copyrightEditable: boolean;
18201826
};
18211827
};
18221828

spec/gen/zod.gen.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ export const zWallet = z.object({
243243
unrestrained: z.number()
244244
})),
245245
stripeAccountId: z.optional(z.string()),
246-
accountType: zAccountType
246+
accountType: zAccountType,
247+
copyrightEditable: z.boolean().default(false)
247248
});
248249

249250
export const zShazamResults = z.array(z.object({
@@ -556,7 +557,8 @@ export const zAdminWallet = z.object({
556557
unrestrained: z.number()
557558
})),
558559
stripeAccountId: z.optional(z.string()),
559-
accountType: zAccountType
560+
accountType: zAccountType,
561+
copyrightEditable: z.boolean().default(false)
560562
}).and(z.object({
561563
email: z.email().regex(/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/),
562564
userName: z.string(),
@@ -951,7 +953,8 @@ export const zPatchIdByWalletsByAdminData = z.object({
951953
unrestrained: z.number()
952954
})),
953955
stripeAccountId: z.optional(z.string()),
954-
accountType: z.optional(zAccountType)
956+
accountType: z.optional(zAccountType),
957+
copyrightEditable: z.optional(z.boolean()).default(false)
955958
})),
956959
path: z.object({
957960
id: z.string()
@@ -1224,7 +1227,9 @@ export const zGetIdByDropsByMusicResponse = z.object({
12241227
_id: z.optional(z.string()),
12251228
user: z.optional(z.string()),
12261229
type: z.optional(zDropType)
1227-
});
1230+
}).and(z.object({
1231+
copyrightEditable: z.optional(z.boolean())
1232+
}));
12281233

12291234
export const zPatchIdByDropsByMusicData = z.object({
12301235
body: z.optional(z.object({
@@ -1695,7 +1700,8 @@ export const zGetWalletResponse = z.object({
16951700
unrestrained: z.number()
16961701
})),
16971702
stripeAccountId: z.optional(z.string()),
1698-
accountType: zAccountType
1703+
accountType: zAccountType,
1704+
copyrightEditable: z.boolean().default(false)
16991705
});
17001706

17011707
export const zPutWalletData = z.object({

0 commit comments

Comments
 (0)