Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External File Storage: Allow to suggest a filename in SaveFile #3273

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ codeunit 9454 "External File Storage"
var
DefaultSaveFileTitleLbl: Label 'Save as';
begin
exit(SaveFile(Path, FileExtension, DefaultSaveFileTitleLbl));
exit(SaveFile(Path, '', FileExtension, DefaultSaveFileTitleLbl));
end;

/// <summary>
Expand All @@ -236,7 +236,20 @@ codeunit 9454 "External File Storage"
/// <returns>Returns the selected file path.</returns>
procedure SaveFile(Path: Text; FileExtension: Text; DialogTitle: Text): Text
begin
exit(ExternalFileStorageImpl.SaveFile(Path, FileExtension, DialogTitle));
exit(SaveFile(Path, '', FileExtension, DialogTitle));
end;

/// <summary>
/// Opens a save to dialog.
/// </summary>
/// <param name="Path">Start path of the dialog.</param>
/// <param name="FileNameSuggestion">Suggested file name for the dialog.</param>
/// <param name="FileExtension">The file extension without dot (like pdf or txt).</param>
/// <param name="DialogTitle">Title of the selection dialog.</param>
/// <returns>Returns the selected file path.</returns>
procedure SaveFile(Path: Text; FileNameSuggestion: Text; FileExtension: Text; DialogTitle: Text): Text
begin
exit(ExternalFileStorageImpl.SaveFile(Path, FileNameSuggestion, FileExtension, DialogTitle));
end;

/// <summary>
Expand All @@ -246,4 +259,4 @@ codeunit 9454 "External File Storage"
begin
ExternalFileStorageImpl.BrowseAccount();
end;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ codeunit 9455 "External File Storage Impl."
exit(CombinePath(TempFileAccountContent."Parent Directory", TempFileAccountContent.Name));
end;

procedure SaveFile(Path: Text; FileExtension: Text; DialogTitle: Text): Text
procedure SaveFile(Path: Text; FileNameSuggestion: Text; FileExtension: Text; DialogTitle: Text): Text
var
StorageBrowser: Page "Storage Browser";
FileName, FileNameWithExtension : Text;
Expand All @@ -199,7 +199,7 @@ codeunit 9455 "External File Storage Impl."

StorageBrowser.SetPageCaption(DialogTitle);
StorageBrowser.SetFileAccount(TempCurrFileAccount);
StorageBrowser.EnableSaveFileLookupMode(Path, FileExtension);
StorageBrowser.EnableSaveFileLookupMode(Path, FileNameSuggestion, FileExtension);
if StorageBrowser.RunModal() <> Action::LookupOK then
exit('');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,13 @@ page 9455 "Storage Browser"
BrowseFolder(Path);
end;

internal procedure EnableSaveFileLookupMode(Path: Text; FileExtension: Text)
internal procedure EnableSaveFileLookupMode(Path: Text; FileNameSuggestion: Text; FileExtension: Text)
var
FileFilterTok: Label '*.%1', Locked = true;
begin
ShowFileName := true;
FileFilter := StrSubstNo(FileFilterTok, FileExtension);
SaveFileName := FileNameSuggestion;
EnableLookupMode();
BrowseFolder(Path);
end;
Expand Down Expand Up @@ -204,4 +205,4 @@ page 9455 "Storage Browser"
begin
FileAccountBrowserMgt.BrowseFolder(Rec, Path, CurrentPath, DoNotLoadFiles, FileFilter);
end;
}
}
Loading