Skip to content

Commit

Permalink
add github pack editor, pack page is out
Browse files Browse the repository at this point in the history
  • Loading branch information
3vorp committed Jan 19, 2024
1 parent 0dc1d05 commit 22316be
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 7 deletions.
61 changes: 59 additions & 2 deletions pages/pack/pack_creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,40 @@ export default {
:label="$root.lang().database.labels.pack_id">
</v-text-field>
<v-text-field :color="color" required clearable v-model="formData.name" :label="$root.lang().database.labels.pack_name"></v-text-field>
<v-select :color="color" :item-color="color" required multiple deletable-chips small-chips v-model="formData.tags" :items="tags" :label="$root.lang().database.labels.pack_tags"></v-select>
<v-combobox
:color="color"
:item-color="color"
required
multiple
deletable-chips
small-chips
v-model="formData.tags"
:items="tags"
:label="$root.lang().database.labels.pack_tags">
</v-combobox>
<v-text-field :color="color" required type="number" v-model="formData.resolution" :label="$root.lang().database.labels.pack_resolution"></v-text-field>
<v-text-field :color="color" :rules="downloadLinkRules" clearable v-model="formData.logo" :label="$root.lang().database.labels.pack_logo"></v-text-field>
<h2 class="title">{{ $root.lang().database.subtitles.github }}</h2>
<p class="text-caption">{{ $root.lang().database.hints.github_required }}</p>
<div v-for="(edition, index) in editions" :key="index">
<p class="text-body-1">{{ toTitleCase(edition) }}</p>
<v-row>
<v-col>
<v-text-field
:color="color"
:label="$root.lang().database.labels.github_org"
v-model="(formData.github[edition] || createNewGithub(edition)).org">
</v-text-field>
</v-col>
<v-col>
<v-text-field
:color="color"
:label="$root.lang().database.labels.github_repo"
v-model="(formData.github[edition] || createNewGithub(edition)).repo">
</v-text-field>
</v-col>
</v-row>
</div>
<h2 class="title">{{ $root.lang().database.subtitles.submissions }}</h2>
<div v-if="Object.keys(formData.submission).length">
<v-container>
Expand Down Expand Up @@ -124,6 +155,7 @@ export default {
github: {},
submission: {},
},
editions: [],
downloadLinkRules: [(u) => this.validURL(u) || this.$root.lang().database.labels.invalid_url],
submissionOpen: false,
submissionData: {},
Expand Down Expand Up @@ -184,14 +216,17 @@ export default {
); // fragment locator
return pattern.test(str);
},
toTitleCase(val) {
return val[0].toUpperCase() + val.slice(1);
},
addSubmissionData(data) {
if (!this.submissionAdd) return;
this.formData.submission = data || {};
},
send() {
const data = { ...this.formData };

// if user doesn't specify id on pack creation, the API will assume it
// if user doesn't specify id on pack creation (falsy), the API will assume it
if (this.add) {
if (!data.submission.id) delete data.submission.id;
if (!data.id) delete data.id;
Expand All @@ -200,6 +235,16 @@ export default {
// stop accidental casting
if (!data.logo) data.logo = null;

Object.entries(data.github).forEach(([k, v]) => {
if (!v.repo || !v.org) delete data.github[k];
});

if (!Object.keys(data.github).length)
return this.$root.showSnackBar(
"At least one GitHub repository needs to be present.",
"error",
);

// only add submission property if filled out
if (
!this.submissionAdd || // if changing submission, already done separately
Expand All @@ -223,6 +268,18 @@ export default {
this.$root.showSnackBar(err, "error");
});
},
createNewGithub(edition) {
this.formData.github[edition] = {
org: null,
repo: null,
};
return this.formData.github[edition];
},
},
created() {
axios.get(`${this.$root.apiURL}/textures/editions`).then((res) => {
this.editions = res.data;
});
},
computed: {
dialogTitle() {
Expand Down
12 changes: 8 additions & 4 deletions resources/strings/en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
contributions: "contributions",
users: "users",
textures: "textures",
packs: "packs (under construction)",
packs: "packs",
files: "files",
mods: "mods",
modpacks: "modpacks",
Expand Down Expand Up @@ -138,6 +138,7 @@ export default {
no_contributor_yet: "No contributor yet",
pack: "Resource Packs",
submissions: "Submission information",
github: "GitHub",
resource_packs: "Filter by pack",
channels: "Discord channels",
contributor: "User",
Expand Down Expand Up @@ -187,6 +188,8 @@ export default {
council: "Council channel",
results: "Results channel",
},
github_org: "Organization",
github_repo: "Repository",
submission_reference: "Reference pack",
edit_submission: "Edit submission information",
invalid_url: "This URL is not valid",
Expand All @@ -202,13 +205,13 @@ export default {
select_pack_type: "Filter by tag",
username: "Username",
uuid: "Minecraft profile UUID",
texture_name: "Texture Name",
texture_type: "Texture Tags",
texture_name: "Texture name",
texture_type: "Texture tags",
texture_id: "Texture ID",
texture_uses: "Texture use(s)",
use_name: "Use name",
use_id: "Use ID",
use_edition: "Use Edition",
use_edition: "Use edition",
path: "Path",
path_id: "Path ID",
versions: "Versions",
Expand All @@ -226,6 +229,7 @@ export default {
pack_id_editing: "Changing a pack ID can break everything!",
pack_reference: "Pack to compare against in submission embeds.",
submission_timings: "Delays are measured in days.",
github_required: "An edition can be left blank if it's not yet supported.",
channel_ids: "Enable Developer Mode and right click on a channel to get channel IDs.",
texture_id: "Changing the texture ID can break everything!",
use_id: "Changing the use ID can break everything!",
Expand Down
2 changes: 1 addition & 1 deletion webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const ALL_TABS = [
],
},
{
enabled: window.DEV,
enabled: true,
icon: "mdi-cube",
label: "packs",
routes: [
Expand Down

0 comments on commit 22316be

Please sign in to comment.