tags: remove some filters
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/877/head
parent
d73d96ed27
commit
c8c6f1f8a1
|
@ -33,6 +33,10 @@ class TagsController extends GenericApiController
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
|
* @param int $id File ID
|
||||||
|
* @param int[] $add Tags to add
|
||||||
|
* @param int[] $remove Tags to remove
|
||||||
|
*
|
||||||
* Set tags for a file
|
* Set tags for a file
|
||||||
*/
|
*/
|
||||||
public function set(int $id, array $add, array $remove): Http\Response
|
public function set(int $id, array $add, array $remove): Http\Response
|
||||||
|
|
|
@ -67,13 +67,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
tagFilter(element: dav.ITag, index: number) {
|
tagFilter(element: dav.ITag, index: number) {
|
||||||
return (
|
return element.displayName !== '' && element.canAssign && element.userAssignable && element.userVisible;
|
||||||
element.id >= 2 &&
|
|
||||||
element.displayName !== '' &&
|
|
||||||
element.canAssign &&
|
|
||||||
element.userAssignable &&
|
|
||||||
element.userVisible
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
tagLabel({ displayName }: dav.ITag) {
|
tagLabel({ displayName }: dav.ITag) {
|
||||||
|
@ -82,7 +76,7 @@ export default defineComponent({
|
||||||
|
|
||||||
createOption(newDisplayName: string): dav.ITag {
|
createOption(newDisplayName: string): dav.ITag {
|
||||||
// do not create tags that already exist
|
// do not create tags that already exist
|
||||||
const existing = this.getAvailable().find((x) => x.displayName === newDisplayName && this.tagFilter(x, 0));
|
const existing = this.getAvailable().find((x) => x.displayName === newDisplayName);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ export async function createTag(tag: ITag): Promise<ITag> {
|
||||||
const postData = {
|
const postData = {
|
||||||
...tag,
|
...tag,
|
||||||
name: tag.displayName, // weird
|
name: tag.displayName, // weird
|
||||||
|
id: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -56,6 +57,13 @@ export async function createTag(tag: ITag): Promise<ITag> {
|
||||||
|
|
||||||
throw new Error(t('memories', 'No content-location header found'));
|
throw new Error(t('memories', 'No content-location header found'));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error?.status === 409) {
|
||||||
|
// Tag already exists. Now this may happen e.g. if the tag isn't
|
||||||
|
// assignable or visible to the user and cause problems later.
|
||||||
|
// But that's not our problem here.
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
t('memories', 'Failed to create tag {name}: {error}', {
|
t('memories', 'Failed to create tag {name}: {error}', {
|
||||||
name: tag.displayName,
|
name: tag.displayName,
|
||||||
|
|
Loading…
Reference in New Issue