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

Copy to clipboard in query builder #6584

Merged
merged 2 commits into from
Oct 29, 2019
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 @@ -31,6 +31,7 @@
vm.datePickerChange = datePickerChange;
vm.submit = submit;
vm.close = close;
vm.copyQuery = copyQuery;

function onInit() {

Expand Down Expand Up @@ -120,6 +121,11 @@
query.filters.push({});
}

function copyQuery() {
var copyText = $scope.model.result.queryExpression;
navigator.clipboard.writeText(copyText);
}

function trashFilter(query, filter) {
for (var i = 0; i < query.filters.length; i++) {
if (query.filters[i] == filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,164 +15,160 @@
<umb-box>
<umb-box-content>

<div class="umb-control-group umb-querybuilder">

<div class="row">
<div class="query-items">

<span><localize key="template_iWant">I want</localize></span>

<div class="btn-group">

<umb-button
type="button"
button-style="outline"
action="vm.contentTypeSelectOpen = !vm.contentTypeSelectOpen"
label="{{vm.query.contentType.name}}"
show-caret="true">
</umb-button>
<div class="umb-control-group umb-querybuilder">

<umb-dropdown ng-if="vm.contentTypeSelectOpen" on-close="vm.contentTypeSelectOpen = false">
<umb-dropdown-item ng-repeat="contentType in vm.contentTypes">
<a href ng-click="vm.setContentType(contentType); vm.contentTypeSelectOpen = false;">
{{contentType.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>
<div class="row">
<div class="query-items">

<span><localize key="template_from">from</localize></span>

<umb-button
type="button"
button-style="outline"
action="vm.chooseSource(vm.query)"
label="{{vm.query.source.name}}">
</umb-button>

</div>

<div class="query-items" ng-repeat="filter in vm.query.filters ">

<span ng-if="$first">
<localize key="template_where">where</localize>
</span>
<span ng-if="!$first">
<localize key="template_and">and</localize>
</span>

<div class="btn-group">

<umb-button
type="button"
button-style="outline"
action="vm.propertyFilterOpen[$index] = !vm.propertyFilterOpen[$index]"
label="{{filter.property.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.propertyFilterOpen[$index]" on-close="console.log(1);vm.propertyFilterOpen[$index] = false">
<umb-dropdown-item ng-repeat="property in vm.properties">
<a href ng-click="vm.setFilterProperty(filter, property); vm.propertyFilterOpen[$parent.$parent.$index] = false;">
{{property.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<div class="btn-group" ng-if="filter.property">

<umb-button
type="button"
button-style="outline"
action="vm.termFilterOpen[$index] = !vm.termFilterOpen[$index]"
label="{{filter.term.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.termFilterOpen[$index]" on-close="vm.termFilterOpen[$index] = false">
<umb-dropdown-item ng-repeat="term in vm.getPropertyOperators(filter.property)">
<a href ng-click="vm.setFilterTerm(filter, term); vm.termFilterOpen[$parent.$parent.$index] = false;">
{{term.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<span ng-switch="filter.term.appliesTo[0]">

<!-- Filter term types (string, int, date) -->
<input type="text" ng-switch-when="string" style="width:90px; margin-bottom: 0;" ng-model="filter.constraintValue" ng-change="vm.changeConstraintValue()" />
<input type="number" ng-switch-when="int" style="width:90px; margin-bottom: 0;" ng-model="filter.constraintValue" ng-change="vm.changeConstraintValue()" />

<span ng-switch-when="datetime">
<umb-date-time-picker
options="vm.datePickerConfig"
on-change="vm.datePickerChange(dateStr, filter)">
</umb-date-time-picker>
</span>

</span>

<a href ng-click="vm.addFilter(vm.query)">
<i class="icon-add"></i>
</a>

<a href ng-click="vm.trashFilter(vm.query, filter)">
<i class="icon-trash"></i>
</a>

</div>

<div class="query-items">

<span><localize key="template_orderBy">order by</localize></span>

<div class="btn-group">

<umb-button
type="button"
button-style="outline"
action="vm.sortPropertyOpen = !vm.sortPropertyOpen"
label="{{vm.query.sort.property.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.sortPropertyOpen" on-close="vm.sortPropertyOpen = false">
<umb-dropdown-item ng-repeat="property in vm.properties">
<a href ng-click="vm.setSortProperty(vm.query, property); vm.sortPropertyOpen = false;">
{{property.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<umb-button
ng-show="vm.query.sort.property.name"
type="button"
button-style="outline"
action="vm.changeSortOrder(vm.query)"
label="{{vm.query.sort.translation.currentLabel}}">
</umb-button>

</div>
</div>
<span><localize key="template_iWant">I want</localize></span>

<div class="btn-group">

<umb-button type="button"
button-style="outline"
action="vm.contentTypeSelectOpen = !vm.contentTypeSelectOpen"
label="{{vm.query.contentType.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.contentTypeSelectOpen" on-close="vm.contentTypeSelectOpen = false">
<umb-dropdown-item ng-repeat="contentType in vm.contentTypes">
<a href ng-click="vm.setContentType(contentType); vm.contentTypeSelectOpen = false;">
{{contentType.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<span><localize key="template_from">from</localize></span>

<umb-button type="button"
button-style="outline"
action="vm.chooseSource(vm.query)"
label="{{vm.query.source.name}}">
</umb-button>

</div>

<div class="query-items" ng-repeat="filter in vm.query.filters ">

<span ng-if="$first">
<localize key="template_where">where</localize>
</span>
<span ng-if="!$first">
<localize key="template_and">and</localize>
</span>

<div class="btn-group">

<umb-button type="button"
button-style="outline"
action="vm.propertyFilterOpen[$index] = !vm.propertyFilterOpen[$index]"
label="{{filter.property.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.propertyFilterOpen[$index]" on-close="console.log(1);vm.propertyFilterOpen[$index] = false">
<umb-dropdown-item ng-repeat="property in vm.properties">
<a href ng-click="vm.setFilterProperty(filter, property); vm.propertyFilterOpen[$parent.$parent.$index] = false;">
{{property.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<div class="btn-group" ng-if="filter.property">

<umb-button type="button"
button-style="outline"
action="vm.termFilterOpen[$index] = !vm.termFilterOpen[$index]"
label="{{filter.term.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.termFilterOpen[$index]" on-close="vm.termFilterOpen[$index] = false">
<umb-dropdown-item ng-repeat="term in vm.getPropertyOperators(filter.property)">
<a href ng-click="vm.setFilterTerm(filter, term); vm.termFilterOpen[$parent.$parent.$index] = false;">
{{term.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<span ng-switch="filter.term.appliesTo[0]">

<!-- Filter term types (string, int, date) -->
<input type="text" ng-switch-when="string" style="width:90px; margin-bottom: 0;" ng-model="filter.constraintValue" ng-change="vm.changeConstraintValue()" />
<input type="number" ng-switch-when="int" style="width:90px; margin-bottom: 0;" ng-model="filter.constraintValue" ng-change="vm.changeConstraintValue()" />

<span ng-switch-when="datetime">
<umb-date-time-picker options="vm.datePickerConfig"
on-change="vm.datePickerChange(dateStr, filter)">
</umb-date-time-picker>
</span>

</span>

<a href ng-click="vm.addFilter(vm.query)">
<i class="icon-add"></i>
</a>

<a href ng-click="vm.trashFilter(vm.query, filter)">
<i class="icon-trash"></i>
</a>

</div>

<div class="query-items">

<span><localize key="template_orderBy">order by</localize></span>

<div class="btn-group">

<umb-button type="button"
button-style="outline"
action="vm.sortPropertyOpen = !vm.sortPropertyOpen"
label="{{vm.query.sort.property.name}}"
show-caret="true">
</umb-button>

<umb-dropdown ng-if="vm.sortPropertyOpen" on-close="vm.sortPropertyOpen = false">
<umb-dropdown-item ng-repeat="property in vm.properties">
<a href ng-click="vm.setSortProperty(vm.query, property); vm.sortPropertyOpen = false;">
{{property.name}}
</a>
</umb-dropdown-item>
</umb-dropdown>

</div>

<umb-button ng-show="vm.query.sort.property.name"
type="button"
button-style="outline"
action="vm.changeSortOrder(vm.query)"
label="{{vm.query.sort.translation.currentLabel}}">
</umb-button>

</div>
</div>

<h5>{{model.result.resultCount}} <localize key="template_itemsReturned">items, returned in</localize> {{model.result.executionTime}} ms</h5>

<ul class="nav unstyled">
<li ng-repeat="item in model.result.sampleResults">
<i class="icon icon-document turquoise-d1"></i> {{item.name}}
</li>
</ul>
<ul class="nav unstyled">
<li ng-repeat="item in model.result.sampleResults">
<i class="icon icon-document turquoise-d1"></i> {{item.name}}
</li>
</ul>

<pre>{{model.result.queryExpression}}</pre>
<pre>{{model.result.queryExpression}}</pre>
<a href ng-click="vm.copyQuery()">
<i class="icon-document"></i> <localize key="template_copyToClipboard">copy to clipboard</localize>
</a>

</div>
</div>

</umb-box-content>
</umb-box>
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,7 @@ To manage your website, simply open the Umbraco back office and start adding con
</key>
<key alias="queryBuilder">Query builder</key>
<key alias="itemsReturned">items returned, in</key>
<key alias="copyToClipboard">copy to clipboard</key>
<key alias="iWant">I want</key>
<key alias="allContent">all content</key>
<key alias="contentOfType">content of type "%0%"</key>
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco/config/lang/en_us.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ To manage your website, simply open the Umbraco back office and start adding con
</key>
<key alias="queryBuilder">Query builder</key>
<key alias="itemsReturned">items returned, in</key>
<key alias="copyToClipboard">copy to clipboard</key>
<key alias="iWant">I want</key>
<key alias="allContent">all content</key>
<key alias="contentOfType">content of type "%0%"</key>
Expand Down