Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mth-login-form
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetaboHUB
web-components
mth-login-form
Commits
388d4ff3
Commit
388d4ff3
authored
1 week ago
by
LIOTIER MARION
Browse files
Options
Downloads
Patches
Plain Diff
debug date as string
parent
33d3dffd
No related branches found
No related tags found
No related merge requests found
Pipeline
#301541
passed with warnings
1 week ago
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/MthLoginForm.vue
+9
-6
9 additions, 6 deletions
src/components/MthLoginForm.vue
src/composables/__tests__/utils.spec.ts
+32
-0
32 additions, 0 deletions
src/composables/__tests__/utils.spec.ts
src/composables/utils.ts
+22
-0
22 additions, 0 deletions
src/composables/utils.ts
with
63 additions
and
6 deletions
src/components/MthLoginForm.vue
+
9
−
6
View file @
388d4ff3
...
...
@@ -75,18 +75,25 @@
</
template
>
<
script
setup
lang=
"ts"
>
import
{
ref
,
reactive
}
from
"
vue
"
;
import
{
ref
,
reactive
,
computed
}
from
"
vue
"
;
import
{
useDisplay
}
from
"
vuetify
"
;
import
type
{
User
}
from
"
@/types/User
"
;
import
{
dateAsString
}
from
"
@/composables/utils
"
;
// V MODEL
const
errorMessage
=
defineModel
<
string
|
undefined
>
();
// COMPUTED
const
currentDateAsString
=
computed
(():
string
=>
{
const
d
=
new
Date
();
return
dateAsString
(
d
);
});
// DATA
const
form
=
reactive
<
User
>
({
login
:
""
,
password
:
""
,
last_visit_date
:
currentDateAsString
()
,
last_visit_date
:
currentDateAsString
.
value
,
registration_date
:
"
2024-09-23 09:28:00
"
,
});
const
isValid
=
ref
<
boolean
>
();
...
...
@@ -97,10 +104,6 @@ const { mdAndUp } = useDisplay();
const
emits
=
defineEmits
([
"
submit
"
]);
// METHODS
function
currentDateAsString
()
{
const
d
=
new
Date
();
return
`
${
d
.
getFullYear
()}
-
${(
"
0
"
+
d
.
getMonth
()).
slice
(
-
2
)}
-
${
d
.
getDate
()}
${(
"
0
"
+
d
.
getHours
()).
slice
(
-
2
)}
:
${(
"
0
"
+
d
.
getMinutes
()).
slice
(
-
2
)}
:
${(
"
0
"
+
d
.
getSeconds
()).
slice
(
-
2
)}
`
;
}
/**
* Rule for a non null input
* @returns rule
...
...
This diff is collapsed.
Click to expand it.
src/composables/__tests__/utils.spec.ts
0 → 100644
+
32
−
0
View file @
388d4ff3
// Copyright 2025 INRAE
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import
{
describe
,
test
,
expect
}
from
"
vitest
"
;
import
{
dateAsString
}
from
"
../utils
"
;
describe
(
"
dateAsString
"
,
()
=>
{
test
(
"
should return the date as string : January 1, 2025 00:00:00
"
,
()
=>
{
const
d
=
new
Date
(
"
January 1, 2025 00:00:00
"
);
expect
(
dateAsString
(
d
)).
toBe
(
"
2025-01-01 00:00:00
"
);
});
test
(
"
should return the date as string : March 20, 2025 10:30:00
"
,
()
=>
{
const
d
=
new
Date
(
"
March 20, 2025 10:30:00
"
);
expect
(
dateAsString
(
d
)).
toBe
(
"
2025-03-20 10:30:00
"
);
});
test
(
"
should return the date as string : December 5, 2025 23:59:59
"
,
()
=>
{
const
d
=
new
Date
(
"
December 5, 2025 23:59:59
"
);
expect
(
dateAsString
(
d
)).
toBe
(
"
2025-12-05 23:59:59
"
);
});
});
This diff is collapsed.
Click to expand it.
src/composables/utils.ts
0 → 100644
+
22
−
0
View file @
388d4ff3
// Copyright 2025 INRAE
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* Returns a date as a string 'YYYY-MM-DD HH:MM:SS'
* @param d a date
* @returns the date as a string
*/
export
function
dateAsString
(
d
:
Date
):
string
{
return
`
${
d
.
getFullYear
()}
-
${(
"
0
"
+
(
d
.
getMonth
()
+
1
)).
slice
(
-
2
)}
-
${(
"
0
"
+
d
.
getDate
()).
slice
(
-
2
)}
${(
"
0
"
+
d
.
getHours
()).
slice
(
-
2
)}
:
${(
"
0
"
+
d
.
getMinutes
()).
slice
(
-
2
)}
:
${(
"
0
"
+
d
.
getSeconds
()).
slice
(
-
2
)}
`
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment