Skip to content

Commit

Permalink
Remove mention of collection blocks in UI until later refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Jul 27, 2023
1 parent 6a008dc commit 2514963
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 99 deletions.
19 changes: 0 additions & 19 deletions webapp/src/server_fetch_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,6 @@ export function addABlock(item_id, block_type, index = null) {
return block_id_promise;
}

export function addACollectionBlock(collection_id, block_type, index = null) {
console.log("addACollectionBlock called with", collection_id, block_type);
var block_id_promise = fetch_post(`${API_URL}/add-collection-data-block/`, {
collection_id: collection_id,
block_type: block_type,
index: index,
})
.then(function (response_json) {
store.commit("addACollectionBlock", {
collection_id: collection_id,
new_block_obj: response_json.new_block_obj,
new_block_insert_index: response_json.new_block_insert_index,
});
return response_json.new_block_obj.block_id;
})
.catch((error) => console.error("Error in addACollectionBlock:", error));
return block_id_promise;
}

export function saveItem(item_id) {
console.log("saveItem Called!");
var item_data = store.state.all_item_data[item_id];
Expand Down
27 changes: 0 additions & 27 deletions webapp/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,33 +132,6 @@ export default createStore({
state.all_item_data[item_id]["display_order"].push(new_block_id);
}
},
addACollectionBlock(state, { collection_id, new_block_obj, new_block_insert_index }) {
// payload: item_id, new_block_obj, new_display_order

// I should actually throw an error if this fails!
console.assert(
collection_id == new_block_obj.collection_id,
"The block has a different collection_id (%s) than the collection_id provided to addACollectionBlock (%s)",
collection_id,
new_block_obj.collection_id
);
console.log(
`addACollectionBlock called with: ${collection_id}, ${new_block_obj}, ${new_block_insert_index}`
);
let new_block_id = new_block_obj.block_id;
state.all_collection_data[collection_id]["blocks_obj"][new_block_id] = new_block_obj;
if (new_block_insert_index) {
state.all_collection_data[collection_id]["display_order"].splice(
new_block_insert_index,
0,
new_block_id
);
}
// if new_block_insert_index is None, then block is inserted at the end
else {
state.all_collection_data[collection_id]["display_order"].push(new_block_id);
}
},
updateBlockData(state, payload) {
// requires the following fields in payload:
// item_id, block_id, block_data
Expand Down
53 changes: 2 additions & 51 deletions webapp/src/views/CollectionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,6 @@
</span>
<div class="navbar-nav">
<a class="nav-item nav-link" href="/">Home</a>
<div class="nav-item dropdown">
<a
class="nav-link dropdown-toggle ml-2"
id="navbarDropdown"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
@click="isMenuDropdownVisible = !isMenuDropdownVisible"
>
Add a block
</a>
<div
class="dropdown-menu"
style="display: block"
aria-labelledby="navbarDropdown"
v-show="isMenuDropdownVisible"
>
<template v-for="(blockType, id) in blockTypes" :key="id">
<a
v-if="blockTypes[id].supportsCollections == true"
class="dropdown-item"
@click="newBlock($event, id)"
>
{{ blockType.description }}
</a>
</template>
</div>
</div>
<a class="nav-item nav-link" :href="this.collectionApiUrl" target="_blank">
<font-awesome-icon icon="code" fixed-width /> View JSON
</a>
Expand All @@ -62,19 +33,15 @@
<!-- Item-type header information goes here -->
<div class="editor-body">
<CollectionInformation :collection_id="collection_id" />

<div class="container">
<hr />
</div>
</div>
</template>

<script>
import CollectionInformation from "@/components/CollectionInformation";
import { getCollectionData, saveCollection, addACollectionBlock } from "@/server_fetch_utils";
import { getCollectionData, saveCollection } from "@/server_fetch_utils";
import FormattedCollectionName from "@/components/FormattedCollectionName.vue";
import tinymce from "tinymce/tinymce";
import { blockTypes, itemTypes } from "@/resources.js";
import { itemTypes } from "@/resources.js";
import { API_URL } from "@/resources.js";
import { formatDistance } from "date-fns";

Expand All @@ -88,20 +55,6 @@ export default {
};
},
methods: {
async newBlock(event, blockType, index = null) {
this.isMenuDropdownVisible = false;
this.isLoadingNewBlock = true;
this.$refs.blockLoadingIndicator.scrollIntoView({
behavior: "smooth",
});
var block_id = await addACollectionBlock(this.item_id, blockType, index);
// close the dropdown and scroll to the new block
var new_block_el = document.getElementById(block_id);
this.isLoadingNewBlock = false;
new_block_el.scrollIntoView({
behavior: "smooth",
});
},
saveCollectionData() {
// trigger the mce save so that they update the store with their content
console.log("save clicked!");
Expand Down Expand Up @@ -132,7 +85,6 @@ export default {
return this.$store.state.saved_status_collections[this.collection_id];
},
lastModified() {
// if (!this.item_data.last_modified) { return "" }
let item_date = this.collection_data.last_modified;
const save_date = new Date(item_date);
return formatDistance(save_date, new Date(), { addSuffix: true });
Expand All @@ -147,7 +99,6 @@ export default {
},
beforeMount() {
this.collectionApiUrl = API_URL + "/collections/" + this.collection_id;
this.blockTypes = blockTypes; // bind blockTypes as a NON-REACTIVE object to the this context so that it is accessible by the template.
},
mounted() {
// overwrite ctrl-s and cmd-s to save the page
Expand Down
2 changes: 0 additions & 2 deletions webapp/src/views/EditPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import TinyMceInline from "@/components/TinyMceInline";
import SelectableFileTree from "@/components/SelectableFileTree";

import FileList from "@/components/FileList";
import Modal from "@/components/Modal";
import FileSelectModal from "@/components/FileSelectModal";
import { getItemData, addABlock, saveItem, updateBlockFromServer } from "@/server_fetch_utils";
import FormattedItemName from "@/components/FormattedItemName";
Expand Down Expand Up @@ -235,7 +234,6 @@ export default {
},
components: {
TinyMceInline,
Modal,
SelectableFileTree,
FileList,
FileSelectModal,
Expand Down

0 comments on commit 2514963

Please sign in to comment.