Skip to content
Open
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
1 change: 1 addition & 0 deletions src/assets/svg-icons/arrows-alt-solid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/components/LibrarySelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
<span :style="{ 'background-color': item.color }"></span>
{{item.name}}
<div class="buttons">
<div v-if="item.type === 'space'" title="Move Selected Space" class="move-selected-space">
<Move @click.native="moveSelectedSpace" class="button" />
</div>
<a @click.stop="duplicateRow(item)" class="duplicate" title="duplicate">
<Copy class="button" />
</a>
Expand All @@ -26,19 +29,39 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
</div>
</div>
</div>
<section class="modals">
<MoveSpaceModal
v-if="showMoveSelectedSpaceModal"
@close="() => {showMoveSelectedSpaceModal = false;}"
/>
</section>
</div>
</template>

<script>
import Delete from './../assets/svg-icons/delete.svg';
import Copy from './../assets/svg-icons/copy_icon.svg';
import Move from './../assets/svg-icons/arrows-alt-solid.svg';
import MoveSpaceModal from './Modals/MoveSpaceModal.vue';

export default {
name: 'LibrarySelect',
props: ['rows', 'selectedItemId', 'selectItem', 'destroyItem', 'duplicateRow'],
components: {
Delete,
Copy,
Move,
MoveSpaceModal,
},
data() {
return {
showMoveSelectedSpaceModal: false,
};
},
methods: {
moveSelectedSpace() {
this.showMoveSelectedSpaceModal = true;
},
},
}
</script>
Expand Down Expand Up @@ -84,6 +107,9 @@ export default {
}
}
}
.buttons {
display: flex;
}
}
// overflow: auto;
// height: calc(100% - 5rem);
Expand Down
87 changes: 87 additions & 0 deletions src/components/Modals/MoveSpaceModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<!-- Floorspace.js, Copyright (c) 2016-2017, Alliance for Sustainable Energy, LLC. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
(1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
(2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
(3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission from the respective party.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->

<template>
<ModalBase
class="save-as-modal"
:title="`Move Selected Space`"
@close="$emit('close')"
>
<div>
<p v-if="this.currentSpace" >{{this.currentSpace.name}}</p>
<i>Adjust from the upperleft X/Y</i>
<div>
<label>X: </label>
<input type="number" id="move-space-x" v-model="x_offset" />
<label>Y: </label>
<input type="number" id="move-space-y" v-model="y_offset" />
<button id="save-move-space" @click="save">Save</button>
</div>
</div>
</ModalBase>
</template>

<script>
import ModalBase from './ModalBase.vue';
import { mapGetters } from 'vuex';

export default {
name: 'MoveSpaceModal',
props: [],
data() {
return {
updateXTo: 0,
updateYTo: 0,
currentFace: undefined,
};
},
mounted() {
if (this.currentStoryDenormalizedGeom.vertices.length > 0) {
const currentFace = this.currentStoryDenormalizedGeom.faces.find(face => face.id === this.currentSpace.face_id);
this.currentFace = currentFace;
this.updateXTo = currentFace.edges[0].v1.x;
this.updateYTo = currentFace.edges[0].v1.y;
}
},
computed: {
...mapGetters({
currentSpace: 'application/currentSpace',
currentStoryDenormalizedGeom: 'application/currentStoryDenormalizedGeom',
}),
x_offset: {
get() { return this.updateXTo },
set(val) { this.updateXTo = val; },
},
y_offset: {
get() { return this.updateYTo },
set(val) { this.updateYTo = val; },
},
},
methods: {
save() {
// determine diff of movement
const xOffset = parseInt(this.updateXTo, 10) - this.currentFace.edges[0].v1.x;
const yOffset = parseInt(this.updateYTo, 10) - this.currentFace.edges[0].v1.y;
this.$store.dispatch('geometry/moveFaceByOffset', {
face_id: this.currentFace.id,
dx: xOffset,
dy: yOffset
});
this.$emit('close');
},
},
components: {
ModalBase,
},
}
</script>

<style lang="scss" scoped>
@import "./../../scss/config";


</style>
1 change: 1 addition & 0 deletions src/store/modules/geometry/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export default {

commit('trimGeometry', { geometry_id, vertsReferencedElsewhere: vertsReferencedByDCs });
},

cloneStoryGeometry(context, payload) {
const currentStory = context.rootGetters['application/currentStoryGeometry'];
context.commit('updateClonedGeometry', { newGeom: payload, currentStoryId: currentStory.id });
Expand Down
7 changes: 3 additions & 4 deletions src/store/modules/geometry/actions/createFaceFromPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export default function createFaceFromPoints(context, payload) {
// split edges where vertices touch them
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes here. Just some clean up.

splitEdges(context, newEdges, newVertices);
});

}

// ////////////////////// HELPERS //////////////////////////// //
Expand Down Expand Up @@ -432,11 +431,11 @@ function replacementEdgeRefs(geometry, dyingEdgeId, newEdges) {
/**
* Returns a list of all the edges that need to be split (i.e. edges that are on top of one another)
*
* @param {*} geometry
* @param {*} spacing
* @param {*} geometry
* @param {*} spacing
* @param {*} newEdges List of new edges added, optional
* @param {*} newVertices List of new vertices added, optional
* @returns
* @returns
*/
export function edgesToSplit(geometry, spacing, newEdges, newVertices) {
const priorIterationEdges = [];
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/specs/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,19 @@ module.exports = {
.assert.containsText('.polygons', 'Space 2 - 2');
finish(browser);
},
'able to move a selected space (issue #376)': (browser) => {
start(browser)
.perform(draw50By50Square)
.click('.move-selected-space')
.clearValue('#move-space-x')
.setValue('#move-space-x', -100)
.clearValue('#move-space-y')
.setValue('#move-space-y', -160)
.click('#save-move-space')
.execute('return window.application.$store.state.geometry[0].vertices', [], ({ value }) => {
browser.assert.equal(value[0].x, -100);
browser.assert.equal(value[0].y, -160);
});
finish(browser);
},
};