-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First draft: create a reusable modal component with the look and feel of b2 modals * Add modal sm size * Create create-folder-modal * Implement create folder function * Update adapter and api to return single resources * Implement create folders * Changed Upload to New string * Changed Upload to New string
- Loading branch information
1 parent
87e8b2f
commit 24d1cdb
Showing
13 changed files
with
310 additions
and
23 deletions.
There are no files selected for viewing
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
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
40 changes: 40 additions & 0 deletions
40
administrator/components/com_media/resources/components/modals/create-folder-modal.vue
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,40 @@ | ||
<template> | ||
<media-modal v-if="$store.state.showCreateFolderModal" :size="'sm'" @close="close()"> | ||
<h3 slot="header">Create a new folder</h3> | ||
<div slot="body"> | ||
<form class="form-horizontal"> | ||
<div class="control-group"> | ||
<label class="control-label" for="folder">Folder</label> | ||
<div class="controls"> | ||
<input type="text" id="folder" placeholder="Folder" v-model="folder"> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div slot="footer"> | ||
<button class="btn btn-danger" @click="close()">Cancel</button> | ||
<button class="btn btn-success" @click="save()">Save</button> | ||
</div> | ||
</media-modal> | ||
</template> | ||
|
||
<script> | ||
import * as types from "./../../store/mutation-types"; | ||
export default { | ||
name: 'create-folder-modal', | ||
methods: { | ||
/* Close the modal instance */ | ||
close() { | ||
this.$store.commit(types.HIDE_CREATE_FOLDER_MODAL); | ||
}, | ||
/* Save the form and create the folder */ | ||
save() { | ||
this.$store.dispatch('createDirectory', { | ||
name: this.folder, | ||
parent: this.$store.state.selectedDirectory, | ||
}); | ||
this.folder = ''; | ||
} | ||
} | ||
} | ||
</script> |
96 changes: 96 additions & 0 deletions
96
administrator/components/com_media/resources/components/modals/modal.vue
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,96 @@ | ||
<template> | ||
<div class="media-modal-backdrop" @click="close()"> | ||
<div class="modal" :class="modalClass" @click.stop> | ||
<div class="modal-header"> | ||
<button v-if="showCloseButton" type="button" class="close" @click="close()">×</button> | ||
<slot name="header"></slot> | ||
</div> | ||
<div class="modal-body"> | ||
<slot name="body"></slot> | ||
</div> | ||
<div class="modal-footer"> | ||
<slot name="footer"></slot> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style> | ||
/** TODO DN extract styles **/ | ||
/** modal-sm styles **/ | ||
.modal.modal-sm { | ||
width: 450px; | ||
margin-left: -225px; | ||
} | ||
@media (max-width: 767px) { | ||
.modal.modal-sm { | ||
width: auto; | ||
margin: 0; | ||
} | ||
} | ||
.modal-body { | ||
width: auto; | ||
padding: 15px; | ||
overflow-y: auto; | ||
} | ||
.media-modal-backdrop { | ||
position: fixed; | ||
z-index: 1040; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background-color: rgba(0, 0, 0, .8); | ||
display: table; | ||
transition: opacity .3s ease; | ||
} | ||
</style> | ||
|
||
<script> | ||
// TODO DN: transition and advanced styling | ||
// TODO DN: perhaps use a better modal than the b2 modal | ||
import * as types from "./../../store/mutation-types"; | ||
export default { | ||
name: 'media-modal', | ||
props: { | ||
/* Whether or not the close button in the header should be shown */ | ||
showClose: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
/* The size of the modal */ | ||
size: { | ||
type: String, | ||
} | ||
}, | ||
computed: { | ||
/* Get the modal css class */ | ||
modalClass() { | ||
return { | ||
'modal-sm': this.size === 'sm', | ||
} | ||
}, | ||
}, | ||
methods: { | ||
/* Close the modal instance */ | ||
close() { | ||
this.$emit('close'); | ||
}, | ||
/* Handle keydown events */ | ||
onKeyDown(event) { | ||
if (event.keyCode == 27) { | ||
this.close(); | ||
} | ||
} | ||
}, | ||
mounted() { | ||
// Listen to keydown events on the document | ||
document.addEventListener("keydown", this.onKeyDown); | ||
}, | ||
beforeDestroy() { | ||
// Remove the keydown event listener | ||
document.removeEventListener('keydown', this.onKeyDown); | ||
}, | ||
} | ||
</script> |
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
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
9 changes: 8 additions & 1 deletion
9
administrator/components/com_media/resources/store/mutation-types.js
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,2 +1,9 @@ | ||
export const SELECT_DIRECTORY = 'SELECT_DIRECTORY'; | ||
export const LOAD_CONTENTS_SUCCESS = 'LOAD_CONTENTS_SUCCESS'; | ||
|
||
// Api handlers | ||
export const LOAD_CONTENTS_SUCCESS = 'LOAD_CONTENTS_SUCCESS'; | ||
export const CREATE_DIRECTORY_SUCCESS = 'CREATE_DIRECTORY_SUCCESS'; | ||
|
||
// Create folder modal | ||
export const SHOW_CREATE_FOLDER_MODAL = 'SHOW_CREATE_FOLDER_MODAL'; | ||
export const HIDE_CREATE_FOLDER_MODAL = 'HIDE_CREATE_FOLDER_MODAL'; |
Oops, something went wrong.