0.4.20 • Published 4 months ago

majra v0.4.20

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

About Majra

Majra is a tool for quickly creating CRUD UI & forms. Make your components reusable by majra.

  • Powerful form generator
  • Lots of ready fields
  • Simplicity in usage
  • Extendable
  • static friendly

Install Majra

npm i --save majra

in vue applications

import Vue from "vue";
import Majra from "majra";

Vue.use(Majra, {
  store, // your store instance
  configs: {},
});

in nuxt applications

import Vue from "vue";
import Majra from "majra";

export default async ({ store }) => {
  Vue.use(Majra, {
    store,
    configs: {},
  });
};

Usage

simple example

<template>
  <DynamicTemplate />
</template>

<script>
import { DynamicTemplate } from "majra";

export default {
  components: {
    DynamicTemplate,
  },

  beforeCreate() {
    this.$majra.init({
      mainRoute: "/product",
      relations: [{ route: "/get-menus-list", key: "Menu" }],
      fields: [
        {
          title: "Product name", // title of field that shows in form and table
          field: "name", // the key of data
          type: "text", // type of field (uses majra textField)
          isHeader: true, // show this field in table
        },
        {
          title: "Menu",
          field: "menu",
          sendKey: "menu_id", // you can change your key when sending the form by sendKey
          type: "select",
          rel: {
            model: "Menu", // the key of data that returns from api call
          },
          props: {
            "item-text": "title",
            "item-value": "id",
          },
          isHeader: true,
        },
      ],
    });
  },
};
</script>

You can also use the form builder

<template>
  <DynamicForm :form="form" :fields="fields" />
</template>

<script>
import { DynamicForm } from "majra";

export default {
  components: {
    DynamicForm,
  },
  data: () => ({
    fields: [
      {
        title: "Product name",
        field: "name",
        type: "text",
      },
      {
        title: "Menu",
        field: "menu",
        sendKey: "menu_id",
        type: "select",
        rel: {
          model: "Menu", // the key of data that returns from api call
        },
        props: {
          "item-text": "title",
          "item-value": "id",
        },
      },
    ],
  }),
};
</script>

How create a field

jsut extend AbstractField from majra and make your field, when you extend AbstractField then necessary data and methods will be available.

<template>
  <div>
    <input :value="value" @input="updateField($event)"/>
  <div>
</template>

<script>
  import {AbstractField} from 'majra';

  export default {
    extends: AbstractField,
  }
</script>

How use it

Just import your component and use it

import YourTextField from "./YourTextField.vue";

export default {
  beforeCreate() {
    this.$majra.init({
      mainRoute: "/product",
      fields: [
        {
          title: "Product name",
          field: "name",
          type: "text",
          component: YourTextField, // this field will replace by YourField
          isHeader: true,
        },
      ],
    });
  },
};

License

The Majra is open-sourced software licensed under the MIT license.

0.4.20

4 months ago

0.4.19

4 months ago

0.4.18

4 months ago

0.4.15

10 months ago

0.4.16

10 months ago

0.4.14

10 months ago

0.4.9

12 months ago

0.4.8

12 months ago

0.4.10

11 months ago

0.4.13

11 months ago

0.4.11

11 months ago

0.4.12

11 months ago

0.4.5

1 year ago

0.4.4

1 year ago

0.4.7

1 year ago

0.4.3

2 years ago

0.3.74

2 years ago

0.3.73

2 years ago

0.3.72

2 years ago

0.3.71

2 years ago

0.3.70

2 years ago

0.3.69

2 years ago

0.3.68

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.64

3 years ago

0.3.63

3 years ago

0.3.62

3 years ago

0.3.61

3 years ago

0.3.60

3 years ago

0.3.67

3 years ago

0.3.66

3 years ago

0.3.65

3 years ago

0.3.59

3 years ago

0.3.58

3 years ago

0.3.57

3 years ago

0.3.56

3 years ago

0.3.53

3 years ago

0.3.52

3 years ago

0.3.51

3 years ago

0.3.50

3 years ago

0.3.55

3 years ago

0.3.54

3 years ago

0.3.49

3 years ago

0.3.47

3 years ago

0.3.42

3 years ago

0.3.46

3 years ago

0.3.45

3 years ago

0.3.44

3 years ago

0.3.43

3 years ago

0.3.31

4 years ago

0.3.30

4 years ago

0.3.39

3 years ago

0.3.38

3 years ago

0.3.36

3 years ago

0.3.35

3 years ago

0.3.34

4 years ago

0.3.33

4 years ago

0.3.32

4 years ago

0.3.41

3 years ago

0.3.40

3 years ago

0.3.29

4 years ago

0.3.20

4 years ago

0.3.28

4 years ago

0.3.27

4 years ago

0.3.26

4 years ago

0.3.25

4 years ago

0.3.24

4 years ago

0.3.23

4 years ago

0.3.22

4 years ago

0.3.21

4 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.3.0

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.9

4 years ago

0.3.17

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.14

4 years ago

0.3.13

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.12

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.3

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.1.22

4 years ago

0.1.23

4 years ago

0.1.24

4 years ago

0.1.25

4 years ago

0.1.26

4 years ago

0.1.20

4 years ago

0.1.21

4 years ago

0.1.13

4 years ago

0.1.14

4 years ago

0.1.15

4 years ago

0.1.16

4 years ago

0.1.17

4 years ago

0.1.18

4 years ago

0.1.19

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.12

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago