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

Globals tweaks #1659

Merged
merged 9 commits into from
Apr 10, 2020
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
3 changes: 2 additions & 1 deletion resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Statamic.app({

components: {
GlobalSearch: require('./components/GlobalSearch.vue').default,
SiteSelector: require('./components/SiteSelector.vue').default,
GlobalSiteSelector: require('./components/GlobalSiteSelector.vue').default,
Login: require('./components/login/login'),
LoginModal: require('./components/login/LoginModal.vue').default,
BaseEntryCreateForm: require('./components/entries/BaseCreateForm.vue').default,
Expand All @@ -116,6 +116,7 @@ Statamic.app({
FormListing: require('./components/forms/Listing.vue').default,
FormSubmissionListing: require('./components/forms/SubmissionListing.vue').default,
GlobalListing: require('./components/globals/Listing.vue').default,
GlobalEditForm: require('./components/globals/EditForm.vue').default,
GlobalPublishForm: require('./components/globals/PublishForm.vue').default,
GlobalCreateForm: require('./components/globals/Create.vue').default,
UserListing: require('./components/users/Listing.vue').default,
Expand Down
1 change: 1 addition & 0 deletions resources/js/bootstrap/fieldtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Vue.component('color-fieldtype', require('../components/fieldtypes/ColorFieldtyp
Vue.component('date-fieldtype', require('../components/fieldtypes/DateFieldtype.vue').default);
Vue.component('fieldset-fieldtype', FieldsetFieldtype);
Vue.component('fields-fieldtype', require('../components/fieldtypes/grid/FieldsFieldtype.vue').default);
Vue.component('global_set_sites-fieldtype', require('../components/globals/Sites.vue').default);
Vue.component('grid-fieldtype', require('../components/fieldtypes/grid/Grid.vue').default);
Vue.component('grid-fieldtype-index', require('../components/fieldtypes/grid/GridIndex.vue').default);
Vue.component('hidden-fieldtype', require('../components/fieldtypes/HiddenFieldtype.vue').default);
Expand Down
45 changes: 45 additions & 0 deletions resources/js/components/GlobalSiteSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<template>

<div class="site-selector">
<dropdown-list>
<template v-slot:trigger>
<button class="flex outline-none px-2 items-center dropdown-toggle anti text-grey hover:text-grey-80">
<i class="site-selector-icon"><slot name="icon" /></i><span class="hidden md:block">{{ activeName }}</span>
</button>
</template>

<dropdown-item
v-for="site in sites" :key="site.handle"
:text="siteNameWithStatus(site)"
:class="{'text-grey hover:text-white': site.handle !== active}"
:redirect="cp_url(`select-site/${site.handle}`)" />
</dropdown-list>
</div>

</template>

<script>
export default {

computed: {
sites() {
return Statamic.$config.get('sites');
},

active() {
return Statamic.$config.get('selectedSite');
},

activeName() {
return _.findWhere(this.sites, { handle: this.active }).name;
}
},

methods: {
siteNameWithStatus(site) {
return [site.name, site.handle === this.active ? '(active)' : ''].join(' ').trim();
}
}

}
</script>
46 changes: 16 additions & 30 deletions resources/js/components/SiteSelector.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,31 @@
<template>

<div class="site-selector">
<dropdown-list>
<template v-slot:trigger>
<button class="flex outline-none items-center dropdown-toggle anti text-grey hover:text-grey-80">
<i class="site-selector-icon"><slot name="icon" /></i><span class="hidden md:block">{{ activeName }}</span>
</button>
</template>

<li v-for="site in sites" :key="site.handle">
<dropdown-item
:text="siteNameWithStatus(site)"
:class="{'text-grey hover:text-white': site.handle !== active}"
:redirect="cp_url(`select-site/${site.handle}`)" />
</li>
</dropdown-list>
</div>
<v-select
class="text-sm"
:value="site"
:clearable="false"
:searchable="false"
:get-option-label="site => site.name"
:options="sites"
@input="$emit('input', $event)"
/>

</template>

<script>
export default {

computed: {
sites() {
return Statamic.$config.get('sites');
},
props: {
sites: { type: Array, required: true },
value: { type: String, required: true },
},

active() {
return Statamic.$config.get('selectedSite');
},
computed: {

activeName() {
return _.findWhere(this.sites, { handle: this.active }).name;
site() {
return _.findWhere(this.sites, { handle: this.value });
}
},

methods: {
siteNameWithStatus(site) {
return [site.name, site.handle === this.active ? '(active)' : ''].join(' ').trim();
}
}

}
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/collections/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

<site-selector
v-if="structureSites.length > 1"
class="mr-2"
:sites="structureSites"
:value="treeSite"
@input="treeSite = $event.handle"
Expand Down Expand Up @@ -145,7 +146,7 @@
<script>
import PageTree from '../structures/PageTree.vue';
import DeleteEntryConfirmation from './DeleteEntryConfirmation.vue';
import SiteSelector from '../structures/SiteSelector.vue';
import SiteSelector from '../SiteSelector.vue';

export default {

Expand Down
148 changes: 0 additions & 148 deletions resources/js/components/globals/Configure.vue

This file was deleted.

Loading