Merge pull request #8668 from scmmishra/hide-file-browser

fix: hide file browser for web forms
This commit is contained in:
sahil28297 2019-10-24 16:28:01 +05:30 committed by GitHub
commit 86e585c1f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 11 deletions

View file

@ -23,12 +23,14 @@
:accept="restrictions.allowed_file_types.join(', ')"
>
</label>
{{ __('choose an') }}
<a href="#" class="text-primary bold"
@click.stop.prevent="show_file_browser = true"
>
{{ __('uploaded file') }}
</a>
<span v-if="!disable_file_browser">
{{ __('choose an') }}
<a href="#" class="text-primary bold"
@click.stop.prevent="show_file_browser = true"
>
{{ __('uploaded file') }}
</a>
</span>
{{ __('or attach a') }}
<a class="text-primary bold" href
@click.stop.prevent="show_web_link = true"
@ -105,7 +107,7 @@
</div>
<FileBrowser
ref="file_browser"
v-if="show_file_browser"
v-if="show_file_browser && !disable_file_browser"
@hide-browser="show_file_browser = false"
/>
<WebLink
@ -127,6 +129,9 @@ export default {
show_upload_button: {
default: true
},
disable_file_browser: {
default: false
},
allow_multiple: {
default: true
},
@ -185,7 +190,7 @@ export default {
return this.files.length > 0
&& this.files.every(
file => file.total !== 0 && file.progress === file.total);
},
}
},
methods: {
dragover() {

View file

@ -12,7 +12,8 @@ export default class FileUploader {
restrictions,
upload_notes,
allow_multiple,
as_dataurl
as_dataurl,
disable_file_browser,
} = {}) {
if (!wrapper) {
this.make_dialog();
@ -33,7 +34,8 @@ export default class FileUploader {
restrictions,
upload_notes,
allow_multiple,
as_dataurl
as_dataurl,
disable_file_browser,
}
})
});

View file

@ -71,7 +71,6 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlData.extend({
if (this.df.options) {
Object.assign(options, this.df.options);
}
this.upload_options = options;
},

View file

@ -111,6 +111,11 @@ frappe.ready(function() {
if (df.fieldtype === "Link") {
df.only_select = true;
}
if (["Attach", "Attach Image"].includes(df.fieldtype)) {
if (!df.options)
df.options = {};
df.options.disable_file_browser = true;
}
});
return form_data;