Skip to content

Commit

Permalink
WIP new folder button
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopagno committed Dec 11, 2024
1 parent 49e5ac2 commit 7144554
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export class StorageFilesResourceService {
return this.httpClient.request<IUploadLink>(link.method, link.href, { body: link.payload });
}

createFolder(href:string, body:{ name:string, parent_id:ID }):Observable<IStorageFile> {
return this.httpClient.post<IStorageFile>(href, body);
}

reset():void {
this.store.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
[content]="file"
></li>
</ul>
<input
*ngIf="addingNewFolder"
#newFolderField
type="text"
id="new_folder_name"
name="new_folder_name"
placeholder="New folder..."
(blur)="newFolderSubmit(newFolderField.value)"
/>
</ng-template>

<ng-template #loadingTemplate>
Expand Down Expand Up @@ -72,6 +81,12 @@
</div>

<div class="spot-action-bar">
<div class="spot-action-bar--left">
<button type="button" class="spot-link spot-action-bar--action" (click)="newFolder()" >
<span class="spot-icon spot-icon_folder op-files-tab--icon op-files-tab--icon_forums"></span>
<span [textContent]="text.buttons.newFolder"></span>
</button>
</div>
<div class="spot-action-bar--right">
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
Component,
ElementRef,
Inject,
ViewChild,
} from '@angular/core';

import { I18nService } from 'core-app/core/i18n/i18n.service';
Expand All @@ -57,6 +58,8 @@ import { map } from 'rxjs/operators';
})
export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
public submitted = false;
public addingNewFolder = false;
@ViewChild('newFolderField') newFolderField!:ElementRef;

public readonly text = {
header: this.i18n.t('js.storages.select_location'),
Expand All @@ -74,6 +77,7 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {
submitEmptySelection: this.i18n.t('js.storages.file_links.selection_none'),
cancel: this.i18n.t('js.button_cancel'),
selectAll: this.i18n.t('js.storages.file_links.select_all'),
newFolder: this.i18n.t('js.storages.new_folder'),
},
tooltip: {
directory_not_writeable: this.i18n.t('js.storages.files.directory_not_writeable'),
Expand Down Expand Up @@ -170,4 +174,27 @@ export class LocationPickerModalComponent extends FilePickerBaseModalComponent {

return this.text.tooltip.file_not_selectable;
}

public newFolder():void {
this.addingNewFolder = true;
// this.newFolderField?.nativeElement?.focus();
}

public newFolderSubmit(value:string):void {
if (!value) {
this.addingNewFolder = false;
return;
}

this.storageFilesResourceService.createFolder(
`${this.storage._links.self.href}/folders`,
{
name: value,
parent_id: this.currentDirectory.id,
},
).subscribe((newlyCreatedDirectory) => {
this.addingNewFolder = false;
this.changeLevel(newlyCreatedDirectory);
});
}
}
1 change: 1 addition & 0 deletions modules/storages/config/locales/js-en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ en:
open_storage: "Open %{storageType}"
select_location: "Select location"
choose_location: "Choose location"
new_folder: "New folder"

types:
nextcloud: "Nextcloud"
Expand Down

0 comments on commit 7144554

Please sign in to comment.