fix project settings licenses

This commit is contained in:
Jake Potrebic 2021-03-17 23:32:23 -07:00
parent fd370dbcd9
commit 5056930ca3
No known key found for this signature in database
GPG Key ID: 7C58557EC9C421F8
5 changed files with 21 additions and 18 deletions

View File

@ -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;
}

View File

@ -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')" />

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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");
}