mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-11-21 01:21:54 +08:00
fix project settings licenses
This commit is contained in:
parent
fd370dbcd9
commit
5056930ca3
@ -94,7 +94,7 @@
|
||||
</v-col>
|
||||
<v-col v-if="isCustomLicense" cols="12" md="8">
|
||||
<v-text-field
|
||||
v-model.trim="form.settings.license.customName"
|
||||
v-model.trim="form.settings.license.name"
|
||||
dense
|
||||
hide-details
|
||||
filled
|
||||
@ -240,9 +240,9 @@ export default class ProjectManagePage extends HangarProjectMixin {
|
||||
support: null,
|
||||
keywords: [],
|
||||
license: {
|
||||
type: '',
|
||||
url: '',
|
||||
customName: '',
|
||||
type: null,
|
||||
url: null,
|
||||
name: null,
|
||||
},
|
||||
forumSync: false,
|
||||
},
|
||||
@ -256,7 +256,16 @@ export default class ProjectManagePage extends HangarProjectMixin {
|
||||
|
||||
created() {
|
||||
Object.assign(this.form.settings, this.project.settings);
|
||||
Object.assign(this.form.settings.license, this.project.settings.license);
|
||||
this.$set(this.form.settings, 'license', {});
|
||||
const index = this.project.settings.license.name ? this.licences.indexOf(this.project.settings.license.name) : -2;
|
||||
if (this.project.settings.license.name && index > -1 && index < this.licences.length - 1) {
|
||||
// license is NOT custom
|
||||
this.$set(this.form.settings.license, 'type', this.project.settings.license.name);
|
||||
} else if (this.project.settings.license.name) {
|
||||
this.$set(this.form.settings.license, 'type', '(custom)');
|
||||
this.$set(this.form.settings.license, 'name', this.project.settings.license.name);
|
||||
}
|
||||
this.$set(this.form.settings.license, 'url', this.project.settings.license.url);
|
||||
this.form.description = this.project.description;
|
||||
this.form.category = this.project.category;
|
||||
}
|
||||
|
@ -161,13 +161,7 @@
|
||||
/>
|
||||
</v-col>
|
||||
<v-col v-if="isCustomLicense" cols="12" md="8">
|
||||
<v-text-field
|
||||
v-model.trim="form.settings.license.customName"
|
||||
dense
|
||||
hide-details
|
||||
filled
|
||||
:label="$t('project.new.step3.customName')"
|
||||
/>
|
||||
<v-text-field v-model.trim="form.settings.license.name" dense hide-details filled :label="$t('project.new.step3.customName')" />
|
||||
</v-col>
|
||||
<v-col cols="12" :md="isCustomLicense ? 12 : 6">
|
||||
<v-text-field v-model.trim="form.settings.license.url" dense hide-details filled :label="$t('project.new.step3.url')" />
|
||||
|
4
frontend/types/api/projects.d.ts
vendored
4
frontend/types/api/projects.d.ts
vendored
@ -21,7 +21,7 @@ declare module 'hangar-api' {
|
||||
watching: boolean;
|
||||
}
|
||||
|
||||
interface Licence {
|
||||
interface License {
|
||||
name: string | null;
|
||||
url: string | null;
|
||||
}
|
||||
@ -31,7 +31,7 @@ declare module 'hangar-api' {
|
||||
issues: string | null;
|
||||
sources: string | null;
|
||||
support: string | null;
|
||||
license: Licence | null;
|
||||
license: License;
|
||||
keywords: string[];
|
||||
forumSync: boolean;
|
||||
}
|
||||
|
6
frontend/types/internal/projects.d.ts
vendored
6
frontend/types/internal/projects.d.ts
vendored
@ -74,9 +74,9 @@ declare module 'hangar-internal' {
|
||||
support: string | null;
|
||||
keywords: string[];
|
||||
license: {
|
||||
type: string;
|
||||
url: string;
|
||||
customName: string;
|
||||
type?: string | null;
|
||||
url: string | null;
|
||||
name: string | null;
|
||||
};
|
||||
forumSync: false;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ public class ProjectLicense {
|
||||
|
||||
@JsonCreator(mode = Mode.DELEGATING)
|
||||
public ProjectLicense(Map<String, String> map) {
|
||||
String licenseName = StringUtils.stringOrNull(map.get("customName"));
|
||||
String licenseName = StringUtils.stringOrNull(map.get("name"));
|
||||
if (licenseName == null) {
|
||||
licenseName = map.get("type");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user