Skip to content

Commit

Permalink
Remove console.logs and add EventBus emits
Browse files Browse the repository at this point in the history
This removes the development debugging logs and adds status indication popups for the top of the page. Fades after 3 seconds
  • Loading branch information
Jacobomara901 committed Sep 11, 2024
1 parent 1fcf1f7 commit ff4d22c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
22 changes: 9 additions & 13 deletions src/components/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<script>
import InventorySetupForm from './InventorySetupForm.vue'
import InventoryItem from './InventoryItem.vue'
import { EventBus } from './eventBus'
export default {
components: {
Expand Down Expand Up @@ -116,7 +117,6 @@ export default {
const itemText = await itemResponse.text();
const itemsArray = itemText ? JSON.parse(itemText) : [];
const itemData = itemsArray[0] || {};
console.log('Item data:', itemData);
// Fetch biblio data using biblio_id from item data
const biblioResponse = await fetch(
Expand All @@ -134,7 +134,6 @@ export default {
const biblioText = await biblioResponse.text();
const biblioData = biblioText ? JSON.parse(biblioText) : {};
window.biblioData = biblioData;
console.log('Biblio data:', biblioData);
// Combine item data and biblio data
const combinedData = { ...itemData, biblio: biblioData };
Expand Down Expand Up @@ -198,7 +197,8 @@ export default {
this.barcode = '';
this.$refs.barcodeInput.focus();
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
console.error(error);
EventBus.emit('message', { text: `Error scanning barcode: ${error.message}`, type: 'error' });
}
},
async checkInItem(barcode) {
Expand All @@ -218,16 +218,13 @@ export default {
if (!response.ok) {
throw new Error('Network response was not ok');
}
console.log('Item checked in successfully');
EventBus.emit('message', { text: 'Item checked in successfully', type: 'status' });
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
EventBus.emit('message', { text: `Error checking in item: ${error.message}`, type: 'error' });
}
},
async updateItemStatus(barcode, fields = {}) {
try {
console.log(this.sessionData);
console.log('inventoryDate:', this.sessionData.inventoryDate);
console.log(fields);
const response = await fetch(
`/api/v1/contrib/interactiveinventory/item/fields`,
{
Expand All @@ -245,9 +242,9 @@ export default {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('Item status updated:', data);
EventBus.emit('message', { text: 'Item statuses updated successfully', type: 'status' });
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
EventBus.emit('message', { text: 'Error updating item statuses', type: 'error' });
}
},
async initiateInventorySession(sessionData) {
Expand All @@ -267,11 +264,10 @@ export default {
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('Session started:', data);
this.sessionData.response_data = data; // Add this line to include the response data in sessionData
} catch (error) {
console.error('There was a problem with the fetch operation:', error);
EventBus.emit('message', { text: `Error starting inventory session ${error.message}`, type: 'error' });
}
},
handleToggleExpand(itemId) {
Expand All @@ -291,7 +287,7 @@ export default {
return values;
})
.catch(error => {
console.error('Error fetching authorized values:', error);
EventBus.emit('message', { type: 'error', text: `Error fetching authorized values: ${error.message}` });
throw error;
});
},
Expand Down
10 changes: 3 additions & 7 deletions src/components/InventoryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@


<script>
import { EventBus } from './eventBus';
export default {
props: {
currentItemWithHighestCallNumber: String,
Expand Down Expand Up @@ -83,10 +85,7 @@ export default {
},
lostReason() {
const lostStatusValue = this.item.lost_status;
console.log('Item lost status value:', lostStatusValue);
console.log('Authorized values:', this.authorizedValues);
const reason = this.authorizedValues[lostStatusValue];
console.log('Resolved reason:', reason);
return reason || 'Unknown';
}
},
Expand All @@ -100,18 +99,15 @@ export default {
if (cachedValues) {
this.authorizedValues = JSON.parse(cachedValues);
console.log('Using cached authorized values:', this.authorizedValues);
} else {
try {
const values = await this.fetchAuthorizedValues(field);
console.log('Fetched values:', values);
// Directly use the values object
this.authorizedValues = values;
sessionStorage.setItem(cacheKey, JSON.stringify(values));
console.log('Fetched and cached authorized values:', this.authorizedValues);
} catch (error) {
console.error('Error setting authorized values:', error);
EventBus.emit('message', { type: 'error', text: 'Error setting authorized values' });
}
}
},
Expand Down
17 changes: 8 additions & 9 deletions src/components/InventorySetupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@
</template>

<script>
import { EventBus } from './eventBus';
export default {
props: {
fetchAuthorizedValues: {
Expand Down Expand Up @@ -218,23 +220,20 @@ export default {
description: item.description
}));
} else {
console.error(`Unexpected result format for ${statusFields[key]}:`, result);
EventBus.emit('message', { type: 'error', text: `Unexpected result format for ${statusFields[key]}, ${result}` });
}
});
console.log('Statuses:', this.statuses);
} catch (error) {
console.error('Error creating statuses:', error);
EventBus.emit('message', { type: 'error', text: `Error creating statuses: ${error.message}` });
}
},
async fetchLibraries() {
try {
const response = await fetch('/api/v1/public/libraries');
const data = await response.json();
this.libraries = data;
console.log ('Libraries:', this.libraries);
} catch (error) {
console.error('Error fetching libraries:', error);
EventBus.emit('message', { type: 'error', text: `Error fetching libraries: ${error.message}` });
}
},
async fetchItemTypes() {
Expand All @@ -243,23 +242,23 @@ export default {
const data = await response.json();
this.iTypes = data;
} catch (error) {
console.error('Error fetching itemTypes:', error);
EventBus.emit('message', { type: 'error', text: `Error fetching itemTypes: ${error.message}` });
}
},
async fetchCollectionCodes() {
try {
const collectionCodes = await this.fetchAuthorizedValues('CCODE');
this.collectionCodes = collectionCodes;
} catch (error) {
console.error(error);
EventBus.emit('message', { type: 'error', text: `Error fetching collection codes: ${error.message}` });
}
},
async fetchShelvingLocations() {
try {
const shelvingLocations = await this.fetchAuthorizedValues('LOC');
this.shelvingLocations = shelvingLocations;
} catch (error) {
console.error(error);
EventBus.emit('message', { type: 'error', text: `Error fetching shelving locations: ${error.message}` });
}
},
toggleItype(itemTypeId) {
Expand Down

0 comments on commit ff4d22c

Please sign in to comment.