-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "saleina-cms", | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"author": { | ||
"name": "Zelalem Mekonen", | ||
"email": "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,113 @@ | ||
<template> | ||
|
||
<div class="image-input"> | ||
|
||
<media-library @input="input" :picker="true" @close="showMediaLibrary = false" v-show="showMediaLibrary" v-model="v"/> | ||
|
||
<div class="input card"> | ||
<media-preview :previewOnly="true" :value="fileName" v-if="fileName"/> | ||
<s-button @click.native="remove" v-if="fileName" class="danger min reverse">Remove File</s-button> | ||
<s-button @click.native="showMediaLibrary = true" class="primary min">Pick File</s-button> | ||
</div> | ||
|
||
<label>{{ label }}</label> | ||
|
||
<label class="error">{{ error }}</label> | ||
|
||
</div> | ||
</template> | ||
|
||
<script> | ||
import MediaLibrary from "../media"; | ||
export default { | ||
name: "file" | ||
name: "file", | ||
components: { | ||
MediaLibrary | ||
}, | ||
props: { | ||
value: { | ||
type: String | ||
}, | ||
label: { | ||
type: String, | ||
required: true | ||
}, | ||
error: { | ||
type: String | ||
} | ||
}, | ||
data() { | ||
return { | ||
showMediaLibrary: false, | ||
v: this.value | ||
} | ||
}, | ||
computed: { | ||
fileName() { | ||
if (!this.v) return undefined; | ||
let parts = this.v.split("/"); | ||
return parts[parts.length - 1]; | ||
} | ||
}, | ||
methods: { | ||
input() { | ||
this.showMediaLibrary = false; | ||
this.$emit("input", this.v); | ||
}, | ||
remove() { | ||
this.v = undefined; | ||
this.$emit("input", undefined); | ||
} | ||
} | ||
}; | ||
</script> | ||
</script> | ||
|
||
<style scoped> | ||
.image-input { | ||
min-height: 60px; | ||
display: flex; | ||
flex-direction: column-reverse; | ||
margin: 10px; | ||
text-align: right; | ||
border-radius: 3px 3px 0 0; | ||
position: relative; | ||
} | ||
.input.card { | ||
display: block; | ||
margin: 0; | ||
box-shadow: none; | ||
min-height: 55px; | ||
border-radius: 0 3px 3px 3px; | ||
border: 2px solid var(--label-background); | ||
text-align: left; | ||
} | ||
button { | ||
margin: 10px; | ||
vertical-align: bottom; | ||
} | ||
.media-preview { | ||
display: inline-block; | ||
vertical-align: bottom; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
title: File | ||
group: widgets | ||
--- | ||
|
||
The file widget allows editors to upload a file or select an existing one from the media library. The path to the file will be saved to the field as a string. | ||
|
||
- **Name:** `file` | ||
- **UI:** file picker button opens media gallery allowing to pick files; displays selected file name | ||
- **Data type:** file path string, based on `media_folder`/`public_folder` configuration | ||
- **Options:** | ||
- `default`: accepts a file path string; defaults to null | ||
- **Example:** | ||
|
||
```yaml | ||
- label: "Document" | ||
name: "document" | ||
widget: "file" | ||
default: "/uploads/doc.pdf" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters