Skip to content

Commit

Permalink
Merge pull request #616 from TheRestartProject/RES-1839_zero_ages
Browse files Browse the repository at this point in the history
RES-1839 Record event age as 0 internally but show it as - or empty
  • Loading branch information
edwh authored Feb 20, 2023
2 parents 84c70ee + 5f2bda3 commit 07866a3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ jobs:

steps:
- checkout
- run: sudo bash -c "echo 'Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries"
- run: sudo apt update
- run: sudo apt install dnsutils openssl zip unzip git libxml2-dev libzip-dev zlib1g-dev libcurl4-openssl-dev iputils-ping default-mysql-client vim libpng-dev libgmp-dev libjpeg-turbo8-dev
- run: sudo apt-get install php-xmlrpc php8.1-intl php8.1-xdebug php8.1-mbstring php8.1-simplexml php8.1-curl php8.1-zip postgresql-client php8.1-gd php8.1-xmlrpc php8.1-mysql php-mysql
Expand Down
21 changes: 20 additions & 1 deletion resources/js/components/DeviceAge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<label class="text-bold">
{{ __('devices.age') }}
</label>
<b-input type="number" @change="$emit('update:age', parseFloat($event))" size="lg" class="marg p-1 text-center" min="0" step="0.5" autocomplete="off" :value="age" :disabled="disabled" />
<b-input type="number" size="lg" class="marg p-1 text-center device-age-edit" min="0" step="0.5" autocomplete="off" v-model="value" :disabled="disabled" />
<span class="text-right mb-1">
{{ __('devices.age_approx') }}
</span>
Expand Down Expand Up @@ -34,6 +34,25 @@ export default {
value: null
}
},
watch: {
age: {
handler: function (val) {
// Ensure we don't show 0.
this.value = val ? val : null
},
immediate: true
},
value(newVal) {
// ...even if we do store it as that.
this.$emit('update:age', newVal ? parseFloat(newVal) : 0)
}
},
methods: {
changeAge() {
this.$nextTick(() => {
})
}
}
}
</script>
<style scoped lang="scss">
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/EventDeviceSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
</span>
</div>
</b-td>
<b-td class="d-none d-md-table-cell">
{{ parseFloat(device.age) }}
<b-td class="d-none d-md-table-cell device-age-summary">
{{ parseFloat(device.age) ? parseFloat(device.age) : '-' }}
</b-td>
<b-td class="d-none d-md-table-cell">
{{ device.shortProblem }}
Expand Down
6 changes: 6 additions & 0 deletions tests/Integration/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ exports.addDevice = async function(page, baseURL, idevents, powered, photo, fixe
await expect(page.locator('.device-photos:visible img')).toHaveCount(1)
}

// Age of device when editing is 0, which should show blank.
await expect(page.locator('.device-age-edit:visible')).toHaveValue('')

// Close the device edit.
await page.locator('.cancel').click()

// Age of device is 0, which should show as 0.
await expect(page.locator('.device-age-summary:visible')).toHaveText('-')
}

exports.unfollowGroup = async function(page, idgroups) {
Expand Down

0 comments on commit 07866a3

Please sign in to comment.