data:() ({
hasText: false
})
meathods: {
showText() {
this.hasText = true
}
hideText() {
this.hasText = false
}
}
<div class="flag flag--ru" @mouseover="showText" @mouseleave="hideText">
<svg>
<use xlink:href="@/assets/svg/svg.svg#flag-ru"></use>
</svg>
</div>
<p v-if="hasText">any text</p>
<div class="apartment-search-result" v-for="(item, index) in showedItems" :key="`apart_${item.id}`">
<p v-if="item.sold === 'yes'"> Показывает толкьо проданные</p>
</div>
:key="`apart_${item.id}`"
:key="item.id"
.router-link-active
и .router-link-exact-active
.router-link-exact-active {
color: red;
}
v-if
v-if
.btn-edit {
color: transparent;
background-color: $dark-gray;
outline: none !important;
border: none;
border-radius: 4px;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
height: rem(40px);
padding: 0 0.3em;
}
let newDates = [];
let originalDates = ["2020-11-06", "2020-07-15", "2020-12-05"]
parseDate() {
this.originalDates.forEach(item => {
let date = new Date(item);
let formatter = new Intl.DateTimeFormat("ru", {
year: "numeric",
month: "long",
day: "numeric"
});
let newDate = formatter.format(date);
newDates.push(newDate);
});
console.log(newDates);
}
<template>
<div class="login">
<div class="container">
<h1>Login</h1>
<form class="form" @submit.prevent="login">
<input
type="text"
placeholder="username"
v-model.trim="form.username"
:class="$v.form.username.$error ? 'invalid-feedback' : ''"
class="input"
/>
<span :class="$v.form.username.$error ? 'showError' : 'hideError'"
>Username is required</span
>
<input
type="password"
placeholder="password"
v-model.trim="form.password"
:class="$v.form.password.$error ? 'invalid-feedback' : ''"
class="input"
/>
<span :class="$v.form.password.$error ? 'showError' : 'hideError'"
>Password is required</span
>
<div class="button">
<button class="btn-login">Login</button>
</div>
</form>
</div>
</div>
</template>
<script>
import { required } from 'vuelidate/lib/validators'
export default {
name: 'login',
head() {
return {
title: 'Login',
meta: [
{
hid: 'login',
name: 'login',
content: 'login content',
},
],
}
},
data: () => ({
form: {
username: '',
password: '',
},
}),
methods: {
login() {
this.$v.form.$touch()
if (this.$v.form.$error) {
return
}
console.log('success')
},
},
mounted() {},
validations: {
form: {
username: { required },
password: { required },
},
},
}
</script>
<template>
<div class="connector">
<p>{{connector}}</p>
</div>
</template>
<script>
export default {
name: "Connector",
data() {
return {
sections: {
length: ""
},
}
},
props: {
connector: String
}
}
</script>
<template>
<div class="module">
<Connector class="connector con1" :connector="input1"/>
<Connector class="connector con2" :connector="input2"/>
<Connector class="connector con3" :connector="output1"/>
<Connector class="connector con4" :connector="output2"/>
</div>
</template>
<script>
import Connector from "components/Connector";
export default {
name: "Module",
components: {Connector},
data() {
return {
input1: 'input1',
input2: 'input2',
output1: 'output1',
output2: 'output2'
}
}
}
</script>
created() {
this.handleView();
window.addEventListener("resize", this.handleView);
console.log(this.pageView);
},
destroyed() {
window.removeEventListener("resize", this.handleView);
console.log(this.pageView);
}
oldTableName = "api_category1"
newTableName = "new_category1"
createTable = 'CREATE TABLE {newTableName} ' \
'(id integer NOT NULL PRIMARY KEY AUTOINCREMENT, ' \
'question text NOT NULL, ' \
'answer text NOT NULL);'
insertIntoTable = 'INSERT INTO {newTableName} (question, answer) SELECT question, answer FROM {oldTableName};'
dropTable = 'DROP TABLE {oldTableName};'
renameTable = 'ALTER TABLE {newTableName} RENAME TO {oldTableName};'
class Category1Details(APIView):
@staticmethod
def get_object(self, id):
try:
return Category1.objects.get(id=id)
except Category1.DoesNotExist:
return HttpResponse(status=status.HTTP_404_NOT_FOUND)
def get(self, request, id):
question = self.get_object(self, id)
serializer = Category1Serializer(question)
return Response(serializer.data)
def delete(self, request, id):
category = self.get_object(self, id)
oldTableName = "api_category1"
newTableName = "new_category1"
category.delete()
cursor = connection.cursor()
cursor.execute(createTable.format(newTableName=newTableName))
cursor.execute(insertIntoTable.format(newTableName=newTableName, oldTableName=oldTableName))
cursor.execute(dropTable.format(oldTableName=oldTableName))
cursor.execute(renameTable.format(newTableName=newTableName, oldTableName=oldTableName))
return Response(status=status.HTTP_204_NO_CONTENT)
.notices .toast .toast-icon {
height: 31px !important;
width: 31px !important;
min-width: 31px !important;
}
<div class="question-card" ref="card">
<p
class="question-text"
ref="cardText"
:style="{ fontSize: fontSize + 'rem' }"
>
{{ text }}
</p>
</div>
<script>
export default {
beforeCreate() {
this.calculateFontSize();
},
mounted() {
this.calculateFontSize();
},
data: () => ({
textWidth: 0,
cardWidth: 0,
cardHeight: 0,
textHeight: 0,
fontSize: 6,
text:
"there is an ejecting or lifting force, acting on a body immersed in a liquid or gas, which is equal to the weight of the volume of the liquid or gas displaced by the part of the body immersed in the liquid or gas –Law of Archimedes\n",
options: {
minSize: 11,
maxSize: 120
}
}),
created() {
window.addEventListener("resize", this.calculateFontSize);
},
destroyed() {
window.removeEventListener("resize", this.calculateFontSize);
},
methods: {
calculateFontSize() {
//get font size of text and card height
let fontSize = this.fontSize;
let textHeight = this.$refs.cardText.clientHeight;
let cardHeight = this.$refs.card.clientHeight - 50;
//compare card height and text height
if (textHeight >= cardHeight) {
this.fontSize = fontSize - 0.1;
} else if (textHeight < cardHeight) {
this.fontSize = fontSize + 0.1;
}
//apply card width and height to category text when resizing window
this.cardWidth = this.$refs.card.clientWidth;
this.cardHeight = this.$refs.card.clientHeight;
this.textWidth = this.$refs.cardText.clientWidth;
this.textHeight = this.$refs.cardText.clientHeight;
}
}
};
</script>
let fontSize = this.fontSize;
let textHeight = this.$refs.cardText.clientHeight;
let cardHeight = this.$refs.card.clientHeight - 50;
if (textHeight >= cardHeight) {
this.fontSize = fontSize - 0.1;
} else if (textHeight < cardHeight) {
this.fontSize = fontSize + 0.1;
}
this.cardWidth = this.$refs.card.clientWidth;
this.cardHeight = this.$refs.card.clientHeight;
this.textWidth = this.$refs.cardText.clientWidth;
this.textHeight = this.$refs.cardText.clientHeight;
import ga.rusanov.backend.model.Video;
import ga.rusanov.backend.service.VideoService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.BDDMockito.given;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@WebMvcTest(controllers = VideoController.class)
class VideoControllerTest {
@MockBean
private VideoService videoService;
@Autowired
private MockMvc mockMvc;
private List<Video> videoList;
@BeforeEach()
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.videoList = new ArrayList<>();
this.videoList.add(new Video(1, "kultas", "https://webnsdf"));
this.videoList.add(new Video(2, "joshua", "https://343heth"));
this.videoList.add(new Video(3, "ambient mix", "https://ambientsome"));
}
@Test
void shouldGetAllVideos() throws Exception{
Mockito.when(videoService.findAll()).thenReturn(videoList);
given(videoService.findAll()).willReturn(videoList);
this.mockMvc.perform(get("/api/video/all"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.*", hasSize(3)));
}
}